Running script in Crontab every 3 days once
I have some Perl scripts which needs to be runned every 3 days once, The following is syntax which I have entered, Can you please let me know, Is this correct or wrong.
30 19 * * */3 root /var/scripts/svn_backup.pl
It's wrong. The last column is the day of week. You probably want to move */3
to the third column (day of month):
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
The */3 is in the wrong column your specification should be
30 19 */3 * * root /var/scripts/svn_backup.pl
The */3 syntax is the same as saying 1,4,7 ... 25,28,31. Note that some months it will run on 31st and the next month it will run on the 1st because the interval specifications do not wrap, they always start at the beginning of a sequence. In this case your script gets run without the required interval.
If you need something to run every 3 days then you would have to run your script every day and have it determine if 3 days have passed and exit/continue as appropriate.
In perl you could do something like
if ( int (time/86400)%3 != 0) {exit 0};
which would run the script every 3 days based on the UNIX epoch.