I need to run a crontab command on the 1st of every month except if the 1st is a Saturday or a Sunday. In that case the command should be run the following Monday.Running the command on Monday 1st, 2nd or 3rd should have done the job but it doesn't seem to work. I've tried this
45 06 1-3 * 1 mycmd.ksh >cmd1.log
45 06 1 * 2-5 mycmd.ksh >cmd2.log
The second command is running everyday at 6h45 According to my understanding it should be running at 06h45 on the 1st of any month if the day is Tuesday through Friday. It ran today Friday the 21st at 6h45 !
Any clue ?
Thanks
Best Answer
As the
man
page forcrontab(5)
makes pretty clear:You will need to write a crontab entry that runs the job on the first, second, and third of every month, and modify the job to check what day it is to decide whether or not to continue.