0

I am trying to Execute a script though crontab : At every minute on every day-of-month from 1 through 5 and every day-of-month from 16 through 23 and on every day-of-week from Monday through Friday. So my expression is * * 1-5,16-23 * 1-5. Today is 14th of the Month and I can see it's still triggered my Script through Crontab.

I assume script being triggered either date is matched or Monday to Friday. Can Anyone help me with this cron expression.

  • I hope crontab(5) helps: `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. One can, however, achieve the desired result by adding a test to the command (see the last example in EXAMPLE CRON FILE below)` and the last example is `0 4 8-14 * * test $(date +\%u) -eq 6 && echo "2nd Saturday"` (Run on every second Saturday of the month) – yvs2014 Jun 14 '23 at 05:54
  • @yvs2014 I am still little confuse, what cron expression do I need to run for the above scenario. – Manish Parida Jun 14 '23 at 06:51
  • there is not totaly clear from the question, which combinatiion day-of-month day-of-week you want to get – yvs2014 Jun 14 '23 at 14:49
  • 1
    If I got it correctly `* * 1-5 * * cmd` fits your first condition (from 1th to 5th day of month), and `* * 16-23 * * sh -c 'd=$(date +\%u); test "$d" -ge 1 -a "$d" -le 5 && cmd'` for the second part (from 16th to 23th day of month, but only if it's not a weekend) – yvs2014 Jun 14 '23 at 14:56
  • @yvs2014 Thanks – Manish Parida Jun 14 '23 at 16:28

0 Answers0