Using the Sawmill Scheduler


Sawmill includes a built-in scheduler which can be used to schedule regular database builds, database updates, database expirations, offline HTML page generation, emailed reports, and more. For instance, you can use it to schedule a profile's database to be updated every day at midnight, so the statistics are never more than a day old. Or you could schedule Sawmill to generate HTML pages from your statistics every week, so you have an offline-browseable HTML snapshot of your weekly statistics. Or you could have it update the database every day, and after that, send you the statistics by email.

Scheduled items can only be run when Sawmill itself is running. The easiest way to do this is to run Sawmill in web server mode. If you need to use Sawmill's scheduler features with CGI mode, you can do it by using an external scheduling program like cron or NT Scheduler to run Sawmill every minute in scheduler mode, i.e. sawmill -scheduler. Sawmill can be called directly from cron or NT Scheduler as well, using a command line to describe the operation to be performed.

A scheduled item consists of a date and time, a profile name (or matching pattern), an operation, and possibly extra options. Sawmill will perform the operation on the profile whenever the date and time match the current date and time. For instance if you choose January, Monday, day 12 of the month, 06:09 as your date and time, and Build Database as the operation, Sawmill will build the database at 6:09 AM on any Monday which is the 12th of January. The current date and time must match all the selections, so it won't run at 6:09 AM on Monday the 13th of January, or at 6:09 AM on Tuesday the 12th of January. Usually, you will select "any month," "any day," or * (which means any hour or any minute) for some of the fields. For instance, to update a database every hour, you might choose any month, any day, any day, *:00, Update Database.

Sawmill calls itself from the command line to perform scheduled tasks. The extra options, if specified, are added to the end of the command line. This makes it possible to perform complex scheduled actions by overriding the default options on the command line. For instance without any extra options, sending email will send the default view by email to the default address, without any filters. But if the options are set to -ss smtp.somewhere.com -rna fromsomeone@somewhere.com -rca someone@somewhere.com -rn single_page_summary -f recentdays:30, the Single-page summary of the past 30 days will be sent to someone@somewhere.com, from fromsomeone@somewhere.com, using the SMTP server at smtp.somewhere.com. A list of available reports can be displayed by running Sawmill from the command line with the "-p profilename -a lr" options.

Sawmill creates a file called TaskLog, in the LogAnalysisInfo directory, which contains a log of all scheduled tasks that have run, as well as logs of all other actions Sawmill has taken (e.g. view statistics, build database from the web interface or command line, etc.). This log can be very helpful if you're trying to debug a problem with the Scheduler.