[CentOS] crontab query

Thu Nov 12 14:58:33 UTC 2020
Jon LaBadie <jcu at labadie.us>

On Wed, Nov 11, 2020 at 10:35:48AM -0600, Frank M. Ramaekers Jr. wrote:
> I need to schedule a process/program every hour on the hour between 9am and
> 4pm on the 2nd through the 9th of each month except on Saturday and Sunday. 
> So, I tried this entry:
> 
> 0 9-16 2-9 * 1-5 ./myprog.sh
> 
> Unfortunately it runs outside of the 2nd through the 9th and still runs on
> Sat. through Sun.
> 
> Is there a way to do this (outside the program itself)?
> 

Perhaps

0 9-16 * * 1-5  [[ $(date +%d) == 0[2-9] ]] && ./myprog.sh

Please replace ./ with full path to myprog.sh

jl
-- 
Jon H. LaBadie                  jcu at labadie.us