Setting up run-periodic-tasks
run-periodic-tasks script can be run from the command line, put into a crontab as a recurring task, or run in daemon mode. The script will also log to stdout and stderr.
The script accepts the following arguments when run:
Using this flag signals to run-periodic-tasks to run itself as a daemon process in the background. In the mode, run-periodic-tasks will never exit and run continuously waiting for work to be done.
Takes as input an integer which indicates the number of seconds to wait before checking for new jobs. This option is only valid when running in daemon mode, and if no value is provided the system defaults to 5.
Takes as input an integer which indicates the number of jobs to process at one time. This option is only valid when running in daemon mode. The default is 10.
A flag which tells the script to log in verbose mode.
When processing a batch of jobs (which are drawn in priority order), items within that batch may be randomly executed in order to reduce contention between multiple daemons working on the job queue. This option is only recommended when multiple daemons are running. This option is new to MT version 4.2.
This option is for developers to use to detect Perl objects that are not reclaimed properly while tasks are being run. This option should be used in conjunction with the
verbose flag and works best when running the script in daemon mode. This option requires the installation of the
Devel::Leak::Object CPAN module. This option is new to MT version 4.2.
The following command tells the script to run as a daemon, log verbosely and output log items.
cd /path/to/mt; perl ./tools/run-periodic-tasks -daemon -verbose >> /var/log/httpd/mt.log &
Alternatively, you can instruct the script silently, like so:
cd /path/to/mt; perl ./tools/run-periodic-tasks -daemon &
The following crontab entry will execute
run-periodic-tasks once every 10 minutes.
0,10,20,30,40,50 * * * * cd /path/to/mt; perl ./tools/run-periodic-tasks -verbose >> /var/log/httpd/mt.log
Warning, the following instructions assume you have some familiarity with the Unix command line.
run-periodic-tasks to run via cron, execute the following commands. First, edit your “crontab:”
prompt> crontab -e
This will open your crontab in your text editor of choice. On a new line in this file, add the following text (changing /path/to/mt accordingly):
0,10,20,30,40,50 * * * * cd /path/to/mt; perl ./tools/run-periodic-tasks
Then save the file and quit your text editor. This will install the new command into your crontab, which will be executed every 10 minutes starting at the top of the hour.