crontab 4th Tuesday of month

Tony Molloy tony.molloy at ul.ie
Sat Jul 28 13:20:07 UTC 2012


On Saturday 28 July 2012 12:03:09 Frank Murphy wrote:
> 15 18 22-28 * 2 /command
> 
> I thought the last tuesday would be covered by above.
> But it has run everyday since 22nd.
> 
> Have googled a bit:
> http://hintsforums.macworld.com/showthread.php?t=25110
> plus other crontab pages.
> 
> 
http://hintsforums.macworld.com/member.php?s=2584787478dc5ab0791da9
> ba8d650aa5&u=28924 15 18 22-28 * * test 'date +\%a' != Tue ||
>  /command
> Am uncertain if above would work ootb.
> 
> man crontab (22 September 2010) doesn't shed light on this.
> 
Try the following

eg.  this picks out the first sunday of the month

07 03 1-7  * * test `date +\%a` =  Sun && /usr/local/bin/backup-full

So

15 18 22-28 * * test 'date +\%a' = Tue && command
 

Tony


More information about the users mailing list