Exports Overview:
For endTB we need to regularly export all of the data in the system so that analysis can be performed on it. We can model this export as a set of CSVs that would have all of the data. These CSVs would be linkable through identifier columns in them. The data managers at the local sites would be able to generate these exports and send them to the central location for analysis, as and when needed.
Background Job to generate the exports:
Since the exports would take some time to generate (depending on the amount of data in the system), it makes sense to have a background job to generate these exports so that they are readily available for the end user and can be quickly and easily downloaded. Thus we have provided a background job "bahmni_batch" that would generate the exports. This background job's schedule and frequency can be adjusted as per requirement
Once the frequency is set, the job would run everyday according to that frequency and generate the exports at a prefixed location. These exports would be accessible for the end user through the bahmni application.
Steps to run the export
The export can be run at any time by following the steps below.
- Login to the server system and open terminal.
Switch to 'bahmni' user using the following command :
Now execute the command below
Scheduling the background job:
Open the terminal and change the user to "bahmni" by executing the command "sudo su bahmni"
List all the cron jobs (background jobs for bahmni user) user following command
Changing/Adding schedule
Below is the crontab generator page one would see when accessing the above mentioned cron generator url. Choose the schedule that you would wish the job to be scheduled for.

- After selecting the schedule from the screenshot shown above, one will see the page below with a field labeled "Command To Execute". Fill the field with /usr/bin/bahmni-batch and then click on "Generate Crontab Line".

- After generating crontab line, one will see that crontab expression is generated and shown at the top of the page (as shown below).

Copy the expression (generated as mentioned above) and go to the terminal again. Execute the below command
- One would see the file that lists all the schedules for different cron jobs. If one have not saved any, one would only see a line in the file which would represent the schedule that has been set for the jobs by default. (11:30PM every day as mentioned previously)

Paste the line copied from the generated expression and save it. This should set the schedule for the background job.
Accessing the error log:
The error log for the background job can be accessed at below mentioned location.