14.4 Crontab File Record
Format
Consider the following script called program in the /appl directory:
#!/usr/bin/ksh print program executed at `date +%H:%M` >> /data/output
Some examples of the crontab entries for scheduling this /appl/program to
run are shown in Table 22:
Table 22: Sample crontab Entries for Scheduling a Running of a
Program
To schedule /appl/program to run every five minutes, you can either use the crontab command or the at command.
Technically, you can define all the values in the hour in five minute intervals starting at 0, 1, 2, 3, or 4, as one of the following crontab entries:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /appl/program 1,6,11,16,21,26,31,36,41,46,51,56 * * * * /appl/program 2,7,12,17,22,27,32,37,42,47,52,57 * * * * /appl/program 3,8,13,18,23,28,33,38,43,48,53,58 * * * * /appl/program 4,9,14,19,24,29,34,39,44,49,54,59 * * * * /appl/program
Alternatively, you can use the at command. For scheduling the /appl/program to run every five minutes, or some short intervals repeatedly, modify the /appl/program file by adding the at command as follows:
#!/usr/bin/ksh at now + 5 minutes -f /appl/program > /dev/null 2>&1 print program executed at `date +%H:%M` >> /data/output
Start the first job with the command:
at now -f appl/program > /dev/null 2>&1
When the /appl/program runs for the first time, it schedules the next run five minutes later. This process repeats itself until you stop it by entering the atq command to get the scheduled job name and then the at -r command to remove the scheduled job.