Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

CRON: Regular Tasks


All Unix systems have a mechanism for running certain applications regularly. The mechanism is through a daemon called crond.

Debian uses cron in a very neat and stylised fashion. Scripts to be run regularly are maintained in one of /etc/cron.daily/, /etc/cron.weekly/, or /etc/cron.monthly/. The entries in /etc/crontab then simply run any scripts in these directories on a regular basis. The daily scripts, by default, are run at 6:25am each day. The weekly scripts are run each Sunday at 6:47am and the monthly scripts are run at 6:52am on the first day of each month. The default /etc/crontab essentially contains just the following lines:



25 6    * * *   root    test -e /usr/sbin/anacron || run-parts --report /etc/cron.daily
47 6    * * 7   root    test -e /usr/sbin/anacron || run-parts --report /etc/cron.weekly
52 6    1 * *   root    test -e /usr/sbin/anacron || run-parts --report /etc/cron.monthly

The first line is read as: 25 minutes past 6am on every day of the month and every month of the year and every day of the week as user root run the rest of the line. The ``rest of the line'' tests to see whether anacron is installed and if not runs the scripts found in /etc/cron.daily/. If anacron is installed then it is used instead to ensure the scripts are run. The anacron package is a replacement for cron that does not assume the local host is always powered on (Unix and GNU/Linux systems rarely require rebooting and are happy to remain powered on indefinitely) and will ensure the regular scripts still get run appropriately when the local host is powered on.

If the default times for cron don't suit (e.g., you like to work early in the morning and get annoyed by the sudden disk whirling each morning at 6:25 am) then simply change the times in /etc/crontab. Unlike traditional versions of cron, the newer versions do not require the running of the crontab command to install the new version when you edit /etc/crontab.

A user can easily add entries to their own crontab (stored in /var/spool/cron/crontabs through the crontab command. Use the -l option to list the current contents and the -e option to edit the crontab file.

Copyright © 1995-2006 [email protected]

 
 
  Published under the terms fo the GNU General Public License Design by Interspire