If we need to run a specific task repetitively, then the solution is to use crontab.
The syntax of the command is as follows:
$ crontab –e
This will open a new editor. The following diagram is the syntax to add tasks. The fields to use for repeating tasks at what time are explained here:
Finally, to save the jobs, use the following:
wq # save and quite crontab job
The following are a few examples of the crontab
command:
Use the following command to run a script every 5 minutes, every day:
5 * * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
Use the following command to run 5 minutes after midnight every day:
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
Use the following command to run at 2.15 P.M. on the first of every month—the output is mailed to Paul:
15 14 1 * * * $HOME/bin/monthly
Use the following command to run at 10 P.M. on weekdays, send the e-mail to
<[email protected]>
:0 22 * * 1-5 sendmail...