3.7.2. Tasks

A task is operation that is executed with some frequency. BundleWorks provides a set of built-in tasks and also allows you to develop your own tasks.

Archiving Logs

One of the tasks built into BundleWorks is a log archiving task. This task looks through all deployment bundles for logs that are older than a certain number of days and archives these logs. The logs are compressed, copied into the BundleWorks work directory (inside 'archives/logs' directory), and deleted. BundleWorks uses the 'Runtime-Logs' attribute in a bundle info file to locate the logs to archive. (If this attribute is not found, no logs are archived for that bundle.)

To enable log archiving, you need to execute this task on a periodic basis, preferably daily. You can use whatever mechanism your OS provides for executing periodic tasks. If cron is available, you can add the following entry to the cron table (with 'crontab -e') to archive logs at 3:30 AM each morning:

30 3 * * * /local/bundleworks/work/bin/bw taskrun archive-logs

Periodic Hooks

BundleWorks also includes four tasks for executing bundle hooks on an hourly, daily, weekly, and monthly basis. These BundleWorks tasks look though all deployed bundles for a script matching the name of the period. For example, the BundleWorks daily task looks for and executes any 'daily' hooks (i.e. daily.sh or daily.bat scripts) found inside deployed bundles. This allows you to implement maintenance tasks for a bundle.

To enable these BundleWorks tasks, you need to tell your OS to execute them on a periodic basis. The following presents sample cron entries for doing this:

10 * * * * /local/bundleworks/work/bin/bw taskrun hourly
20 4 * * * /local/bundleworks/work/bin/bw taskrun daily
30 4 * * 0 /local/bundleworks/work/bin/bw taskrun weekly
40 4 1 * * /local/bundleworks/work/bin/bw taskrun monthly