cron/anacron

Toby Kelsey toby_kelsey at ntlworld.com
Thu May 11 14:45:00 UTC 2006


Alan McKinnon wrote:
> On Wednesday 10 May 2006 03:36, Frank McCormick wrote:
> 
>>  Seeing all the messages here about cron/anacron reminded me of a
>>question - how do I check to see if a job is being run? Anacron
>>checks the timestamps of files., but which files. I find the whole

Anacron files are in /var/spool/anacron/. Only the day part of the timestamp is
relevant but it wont tell you if a job is currently running. Cron job files are
in /var/spool/cron/.  A command like 'pstree' might tell you which jobs are
running under (ana)cron. You can also have job results mailed to you, and then
check your mail to see when a job has finished.  You could create a wrapper
script for your job to show you went is active, eg

#!/bin/sh
touch /tmp/my_job_is_running
do stuff
rm /tmp/my_job_is_running

>>cron/anacron thing very confusing. Why doesn't ubuntu use software
>>that works on all machines, those that are up all the time and
>>those which aren't ?

It should have such software installed as default.  fcron can do this (although
it is still limited/buggy), and in the future either that or a fixed version of
Vixie cron might become the standard cron.  It is a pity Ubuntu has adopted the
incompatible anacron and caused problems, but no distribution is perfect.

Here are the common job requirements standard cron should handle:

1) Run at a specific time, otherwise forget it, eg an alarm.
2) Run at a specific time if possible, otherwise as soon after as possible, eg
reminders.
3) Run during some period, the exact time doesnt matter, eg backup overnight.
4) Run periodically, the timing doesnt matter, eg log rotation.
5) Run a one-off job at a specified time (this is covered by 'at')

Anacron can only do (4), while the most useful function is (2).  The software
that comes closest to this functionality is fcron. Ubuntu should use it as
standard once the bugs are ironed out.  The fact that a core utility breaks when
a machine is turned off and on should not be acceptable for a user-friendly
distribution like Ubuntu.

> cron was designed to run on machines that are up all the time. No sane 
> developer is going to try and extend it - it works, it works well and 
> it ain't broke.

Actually most versions of cron have always failed to cope with changes to the
clock even with an always-on machine, and all machines have down-time which cron
ought to be able to handle but doesn't.  The manual administrative interventions
this then requires is something I thought Ubuntu wanted to avoid.

> The /etc/cron.*ly files have nothing whatsoever to do with cron or 
> anacron.

I suppose in some bizarro world /etc/cron.monthly could have nothing to do with
cron or anacron in the same way that /etc/login.defs could have nothing to do
with login. But names have meanings, and we are in real world:

$ dpkg -S /etc/cron.monthly
scrollkeeper, anacron, cron: /etc/cron.monthly

Note also that run-parts (debianutils) is not mentioned.

Toby




More information about the ubuntu-users mailing list