3

I have following issue.
I need to run same script (with different args) in different 5 different dates.

  • 1x per month
  • 2x per month
  • 3x per month
  • 4x per month
  • every day

My current code:

1x month (run every month 1st day, 9:00)

0 9 1 * * php /script.php 1

2x month (need to setup cron)

? php /script.php 2

3x month (need to setup cron)

? php /script.php 3

4x month (run every Monday, 9:00)

0 9 * * 1 php /script.php 4

every day (run every day, 9:00)

0 9 * * * php /script.php e
Kristaps J.
  • 325
  • 3
  • 10

2 Answers2

4

Crontab help gives you the order of time values

To define the time you can provide concrete values for minute (m), hour (h), day of month (dom), month (mon), and day of week (dow) or use '*'

You did not specify any fixed day, so I'll put sample data for you.

This cron will run every 1st and 15th at midnight

0 0 1,15 * * /script.php 2

This other every 1st,10th and 20th at midnight

0 0 1,10,20 * * /script.php 3
Diego Ferri
  • 2,657
  • 2
  • 27
  • 35
1

This should run at 4pm on day x,y, and z of month 06 (June):

0 0 16 [x],[y],[z] [06] * /whatever.script

Every day is easy:

@daily /whatever.script