Ano-Tech Computers
Enter keyword:

How to schedule tasks using the system crontab (Vixie crond)
Problem:
This article describes how to set up schedules tasks using the system crontab under most Linux systems. It may not apply to all versions of Linux or crond.
 
Solution:
1. Edit the "/etc/crontab" file
2. Run "/etc/rc.d/init.d/crond restart" to activate changes

The format of the system crontab file is as follows:
1 = Minutes
2 = Hour
3 = Day
4 = Month (0= names are OK)
5 = Weekday (0=Sun, 1=Mon etc, names are OK)
6 = Owner
7 = Command
A field may be an asterisk (*), which always stands for first-last''.
A field may me a range, for example 1-4
A field may specify more than one value, using comma without spaces
A field may specify intervals using slash, for example 1-6/2

Examples:
# Nightly backup executed at 5:00am
00 5 * * * root /root/backup/data
# Replicate web server every 30 minutes
00,30 * * * * root /home/httpd/html/replicate quiet

Any error messages or other output from the binaries or scripts executed will be automatically emailed to the job owner. For more information about the system crontab file, see "man 5 crontab".
 
Discuss this solution
Did this article solve your problem? Yes No Did not apply

We welcome anyone who is willing to contribute to this public knowledge base, contact siteadmin@atc.no if you have information you would like to share. The idea is not to replace the commercial support sites, but to publish those hard-to-find solutions you've found yourself looking for over and over again.

Show all articles