Managing Batch Jobs in Mifos
A guide to running batch jobs and processes in Mifos
Overview of Batch Jobs
Batch processes (also known as cron jobs on Unix-based systems) are a series of back-end jobs on a computer that are executed through predefined scripts. Mifos currently has 11 of these batch processes which are scheduled to run nightly. The server must be running for the batch jobs to run.
Mifos users will be automatically logged out when batch jobs run, and no logins are permitted until the batch jobs complete.A message displays on the login screen indicating that cron jobs are running. The recommendation is to run batch jobs after business hours.
Reports run before batch jobs have been completed will not reflect the results of the batch jobs.
Mifos Batch Jobs
Please see Batch Jobs for a functional description of the batch jobs listed below.
- ProductStatus
- CollectionSheetTask
- LoanArrearsTask
- SavingsIntCalcTask
- SavingsIntPostingTask
- ApplyCustomerFeeTask
- RegenerateScheduleTask
- PortfolioAtRiskTask
- GenerateMeetingsForCustomerAndSavingsTask
- LoanArrearsAgingTask
- ApplyCustomerFeeChangesTask
Setup and Configuration
Currently, to change the batch job schedule, you must follow the procedures below (This process is temporary and a feature request has been submitted to allow batch jobs to be configured from the UI). If you have not worked with .war files, please refer to the UsingWarFiles wiki page.
Options for Changing .WAR Files
You must modify Mifos configuration files and then re-deploy the Mifos. You can accomplish this task in two ways. The option you choose will depend on how you deployed Mifos and what you feel comfortable doing.1) Unpack the .war file into the web server directory and modify the files.
- Directions for unpacking .war files and using full directories in your servlet (Jetty, Tomcat, JBoss) can be found on the UsingWarFiles wiki page
2) Unpack the .war, modify the files, create a new .war, and redeploy the .war file.
Steps to modify and repack .war files
1) Unpack the.war file (see UsingWarFiles wiki page)
2) Make the changes the the files as specified below.
3) Rebuild the .war file using jar (see UsingWarFiles wiki page).
4) Deploy the new .war file into the web server deploy directory
Mightn't it be possible (if getResource() is used to find the files) to just place files like task.xml in the application server classpath as mentioned in this thread? (-Adam Monsen, Thu Jan 17 13:17:56 PST 2008)
Changing Batch Schedules and Removing Tasks
Batch jobs are configured in task.xml located here:
trunk/mifos/src/org/mifos/framework/util/resources/batchjobs/task.xml
- There is no UI for configuring the batch jobs.
- The above batch jobs run sequentially.
- The initial starting time can be set in task.xml mentioned above.
- Currently, task.xml is configured by default to run every night at midnight.
- The time is based on the server's system time. On a Windows machine, system time will likely be local time.
To change the batch jobs (you should review the items above on .war file options first):
- Stop Mifos application on the web server.
- Make the changes to task.xml and follow instructions on managing your .war file/deployment.
- To change the time at which the batch jobs run: Change the value of "initial-time" to the desired time of day that you want the batch jobs to start.
- For testing purposes, you can set the time to a value prior to the current time, and this will force the batch jobs to run immediately after starting the application.
- Currently the value of "delay-time" is set to 86400 (seconds. 86400 seconds = 24 hours).
- Because these jobs should run every day, this value should remain unchanged.
- Removing this value would cause the batch jobs to run only 1 time.
- Changing the increment will result in an error.
- To modify which jobs run: You may comment out a <scheduled_task> element using basic xml. For example, note the "<!-- and -->" below to see how to comment out the CollectionSheetTask in XML:
<!-- <task-class-name>CollectionSheetTask</task-class-name> <initial-time>15:15:00</initial-time>...
<scheduler>
<task-class-name>ProductStatus</task-class-name>
<initial-time>15:15:00</initial-time>
<delay-time>86400</delay-time>
</scheduler>
<scheduler>
<delay-time>86400</delay-time>
</scheduler> -->
Monitoring
In the database table scheduled_tasks we log the starting, ending time of the batch job. A status field indicates success or failure:
- 1 for success
- 0 for failure
You can also look in the web server logs for information on errors and job starts and stops. The file will vary, depending upon whether you used Jetty, Tomcat, or JBoss as your application server.
Note: If the batch jobs have not been run consecutively for each day, the start date will be the date after the last time the jobs were run.
For example, e.g. if the batch job should have run on January 5th, but they did not run until January 7th, the start date in the table will reflect January 5th, but the end date will read January 7th. This record does NOT indicate that the batches took two days to run!
