The purpose for a crontab is it sets up a file that contains a list of tasks to be performed regularly, such as data backups and or regular odd jobs that you might run on a daily basis that the machine can be
scheduled to do on its own with no user intervention.
SYNTAX : The syntax of this file is very rigid, meaning you must put the items in the proper fields to make it work
correctly. Otherwise it will not work, just consider yourself warned. There are six fields to a file, each separated by a space. The first five fields specify exactly when the command is
going to be run. The last field, the sixth one is the command itself. The following are the five fields in order.
Field Meaning
1 Minutes after the hour (0-59)
2 Hour, in 24 hour format (0-23) 3 Day of the month (1-31)
4 Month (1-12) 5 Day of the week (0-6, 0 = Sunday)
Note : Asterisks (*) specify when commands are to be run in every instance of the value of the field. For example, an asterisks in the month field would mean that the command will
be run every month. You can also, have like multiple events scheduled within the field, just seperate them with a comma with no spaces.
To Create the file : Creating the file is
very simple, the editor is done in vi, so if you are not familiar with vi you can click here for the command set for vi. Otherwise to create the crontab file type : crontab -e
Options : Example : crontab -?
Where the ? mark is, insert any of the below options to get the corresponding function.
-e Edits the current crontab file, or also creates the file -l Lists the contents of the contab file
-r Removes the crontab file
Related Command : at runs a command at a specified time
Examples : To
run a crontab every morning at 9:30am the line in the crontab file would look like this : 30 9 * * * command
To run a command at 1pm only on the 1st and 15th of the month, the line in the crontab file
would look like this : 0 13 1,15 * * command
GhostRdr
|