Scheduling III
Summary:
- anacron
- Interactive Schedulers
anacron
If you look at '/etc/crontab', the control file for the cron scheduling daemon, you will notice that by default all daily, weekly and monthly system tasks are run between 4 and 5 o'clock in the morning. If your computer isn't turned on during this time, the cron jobs won't be executed.
One solution to this problem would be changing the hour fields to a time when your system is most likely running (I used to change them to 2 pm.).
Another solution would be running the 'anacron' system service.
First you should make sure that 'anacron' is up and running, either via the Mandrake Control Center (System - Services), or by making a shortcut via the command line (as 'root'):
~# chkconfig ––list anacron
to check and
~# chkconfig anacron on
to enable the service.
Note that 'anacron' isn't meant as a replacement for 'cron', it's an add-on.
'anacron', the 'anachronistic command scheduler', uses relative time scales ('once a day / week / month') instead of absolute time scales ('4:15am, Feb 15'). So, even if you 'miss' a particular time or date for which a job is scheduled, it will be executed shortly after you've booted the system. It works like this:
- 'anacron' looks up the 'timestamps' for its jobs in '/var/spool/anacron'. * If according to a time stamp a job is due, 'anacron' will run it. * 'anacron' updates the time stamp for the job.
1 5 cron.daily run-parts /etc/cron.daily 7 10 cron.weekly run-parts /etc/cron.weekly 30 15 cron.monthly run-parts /etc/cron.monthly
- The first field denotes the period in days:
1
7
5
Caveats And Limitations
'anacron' does not replace 'cron' because due to its very nature, it can't execute minutely or hourly scheduled jobs. It doesn't provide a mechanism for running jobs under different users, i.e. all jobs are run as 'root'.
Example: Getting Your New Mail After Boot
You want your computer to get your new mail after having booted it in the morning. Since you boot your machine at different times, a cron job won't do.
You need a properly configured mail daemon, a mail retrieving utility like Fetchmail and a scripted dial-up connection.
Add this command (one line) to '/etc/anacrontab':
1 3 getmail pppd call ISP && fetchmail -s && killall pppd
Since 'anacron' executes all commands as 'root', the '.fetchmailrc' file must have the permissions -rw––- root root set and should ideally reside in 'root's' home directory. Another possibility would be putting the commands into a script and putting su user before the line which starts 'fetchmail'.
Interactive Schedulers
'at', 'cron' and 'anacron' do not allow to start programs which require user input, like X applications. This is because they don't have a shell to start a program from. 'sleep' can do that, but only within a session.
Surprisingly enough there seems to be only one program currently which saves schedules to a file and thus allows to launch arbitrary interactive programs at a given time. This program is called 'rclock' and is part of the 'rxvt' package. If you find others, you are invited to tell me ;).
Related Resources:
man anacron
man anacrontab
man rclock
Revision / Modified: Dec. 25, 2001
Author: Tom Berger
Legal: This page is covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB and Mandrakesoft.
Version 1.3 last modified by AdminWiki on 22/03/2004 at 09:44
Document data
- Lost account?
- Join the community, be part of the Club: it's free!
- Get the PWP Download Subscription!