Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute CRON 2 and 3 times per month?

Tags:

php

cron

execute

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
like image 981
Kristaps J. Avatar asked Dec 30 '25 23:12

Kristaps J.


1 Answers

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
like image 92
Diego Ferri Avatar answered Jan 02 '26 13:01

Diego Ferri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!