Scheduling in crontab
CRONTAB
This is a scheduler at OS level, which we used to schedule the jobs/scripts/commands at a particular time.
Format of crontab is
Minute Hour “DATE OF MONTH” “MONTH” “DAY OF WEEK” COMMAND/SCHRIPT(with full path)
* * * * * COMMAND/SCHRIPT
– – – – –
| | | | |
| | | | +—– day of week (0 – 6) (Sunday=0)
| | | +——- month (1 – 12)
| | +——— day of month (1 – 31)
| +———– hour (0 – 23)
+————- min (0 – 59)
If you want to schedule a script.
execute “crontab -e”, this will open a file in vi editor there you need to give the details when you want to run the script and save the file.
Example:
[root@localhost ~]# cat /tmp/test.sh
echo “I am executing the job `date`” > /tmp/logfile
crontab -e
* * * * * /tmp/test.sh
[root@localhost ~]# cat /tmp/logfile
I am executing the job Mon Dec 18 09:53:01 IST 2017
Here I scheduled the job to run every minute. You can schedule the job as per your requirement.