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)? -Frank
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
Hallo, doesn t it make more sense to start the script every hour and check all conditions in the script? Ralf Von meinem iPad gesendet> Am 12.11.2020 um 15:42 schrieb Frank M. Ramaekers Jr. <frank at ramaekers.com>: > > ?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)? > > -Frank > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos
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)?>From the crontab(5) man page:Note: The day of a command's execution can be specified in the follow? ing two fields ? 'day of month', and 'day of week'. If both fields are restricted (i.e., do not contain the "*" character), the command will be run when either field matches the current time. For example, "30 4 1,15 * 5" would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday. So it looks like it is going to run either time. A systemd timer might be able to be more exclusive, but parsing the 'systemd.time' man page makes my head hurt. -- Jonathan Billings <billings at negate.org>
On Thu, Nov 12, 2020 at 03:59:09PM +0100, Ralf Prengel wrote:> Hallo, > doesn t it make more sense to start the script every hour and check all conditions in the script? > Ralf > > Von meinem iPad gesendetI prefer to develop the script standalone. The date/time restriction can be added in crontab or a separate script that does the date/time validation and calls the standalone script. If the date/time checks are added to the script, I recommend adding an option to override the checks and forces execution of the script when needed. Jon> > > Am 12.11.2020 um 15:42 schrieb Frank M. Ramaekers Jr. <frank at ramaekers.com>: > > > > ?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)? > > > > -Frank > > > > _______________________________________________ > > CentOS mailing list > > CentOS at centos.org > > https://lists.centos.org/mailman/listinfo/centos > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos >>> End of included message <<<-- Jon H. LaBadie jcu at labadie.us