next up previous
Next: 4 Hacking Up: 3 Administration Previous: 3.13 RDFs

Subsections


3.14 Cron

Scoop, like nearly any other weblog, needs to do some things at a set interval. This is where cron comes in. Scoop's cron system is mainly web-based, only requiring one actual crontab job, and that doesn't even have to be on the same server as Scoop. In order to use Scoop's cron, you'll need to have the cron daemon (or some other scheduler) configured correctly on a system that will always be running (or at least, always be running when it needs to be :). For more on setting up cron to run Scoop's cron, see the Notes section (3.14.3).


3.14.1 Usage

Like all of Scoop's admin tools, you access the Cron admin tool using the ``Cron'' link under ``Admin Tools''. Generally, you must be a Superuser to access this (any lesser group probably has no need to access it). When you do, you'll see a table at the top, which lists all of the possible cron jobs. At the far left is a checkbox so that you can perform several actions at once, followed by the name of the cron job, and the internal function it relates to (you can't change this without manually editing the DB because, well, there's no need to). After that is a box setting how often to run the job, the time it was last run, and if it's enabled or not.

Out of these, the ``Run Every'' column is probably the only one that needs some explaining. Basically, it defines how often the job should be run, in units of time between them. The format is ``
sseconds
mminutes
hhours
ddays
wweeks
Mmonths (30 days)
Yyears (365 days)
Note that these numbers will not be honored exactly. It really depends on when the jobs are started, and what order they're in. Scoop will just do it's best to run these as close as possible to their actual times.

Below the table is a row of radio buttons so that you can choose what action to perform on all the selected cron jobs. Force Run will run all selected jobs, regardless of how recently they were run (though if the job is disabled, it still won't run). Toggle Enabled will switch the enabled flag on each selected job, on a per-job basis. If you've changed the Run Every column for any of them, you must choose the next button (Change Run Every) and save. Otherwise, your changes will be lost. Finally, Clear Last Run will reset the last run column, so the next time jobs are run, this one will be included (unless disabled).

After the actions is a link to visit op=cron, which will run any cron jobs that need to be. This is the same URL that will need to be visited every once in awhile by something run from crond.


3.14.2 Individual Cron Job Descriptions

sessionreapRemoves sessions that haven't been used in a certain amount of time.
storyreapNo longer used, will be removed at a later time. (don't enable this, the code for it doesn't exist)
rdfGenerates an RSS feed that syndicates your headlines.
digestSends out story digest mail.
rdf_fetchFetches RSS feeds from other sites. See RDF Admin (3.13).


3.14.3 Notes

While you don't technically have to setup cron to periodically run a script and visit op=cron, you probably want to (or, you could stare at your watch and click ``Run Cron Now'' every once in awhile :). Scoop comes with a script called ``run_cron.pl'' (in the ``scripts/'' directory) to do the work of visiting op=cron, parsing it's return value, and displaying errors, so all you need to do is setup something to run the script every once in awhile.

First, how ``run_cron.pl'' is called. You can get a (most likely) more detailed help message by doing ``run_cron.pl -h'', though it's fairly simple. For most people with only one Scoop site, you just need to do ``run_cron.pl http://www.yoursite.com/cron/''. If you have more sites, you can add the URLs on after that, but this can quickly get nasty. So, ``run_cron.pl'' will also accept a ``-f'' option (actually, it'll accept more than one), which takes a filename as an arg. That file should contain URLs, one per line, which ``run_cron.pl'' will visit. Note that if you're having problems, you can always turn up the debug level (default is 1, errors only, but other possibilities are 0 for no output, 2 for status messages, and 3 for all debug messages).

Once you've got ``run_cron.pl'' figured out, you just need to set it up to run. First choose how often you want it to run. Base this on your lowest ``Run Every'', and aim for below this. So if the lowest is 1 hour, every 30 minutes would probably be best. Note that just because op=cron is being visited doesn't mean jobs are being run.

For users of a Unix-type system, you'll probably use crond, in which case ``man crontab'' for more on managing them, and ``man 5 crontab'' for more on the format of the file. Generally, the one for Scoop will be something like this:

*/30 * * * * /path/to/run_cron.pl http://www.yoursite.com/cron/
(runs every 30 minutes)
* */2 * * * * ...
(runs every 2 hours)
0 * * * * ...
(runs every hour)
etc.


3.14.4 Relevant Vars

While the actual cron code doesn't use any vars, the jobs that it runs do. Here they are, organized by cron job.


3.14.5 Relevant Perms

cron_admin


next up previous
Next: 4 Hacking Up: 3 Administration Previous: 3.13 RDFs