Setting up run-periodic-tasks

The 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:

--daemon

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.

--sleep <seconds>

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.

--load <jobs>

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.

--verbose

A flag which tells the script to log in verbose mode.

--randomly

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.

--leak

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.

Example - Launching a Daemon Process

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 &

Example - Executing from Cron

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
This page was last updated on 2008-05-22, 13:22.  

Leave a note