Is it possible to run a cronjob every three days? Or maybe 10 times/month.
As we already know that the pattern * */2 * * * executes the task for every 2 hour, similary can * * */2 * * execute the task for every 2 day (once in 2 days).
*/5 * * * * Execute a cron job every 5 minutes. 0 * * * * Execute a cron job every hour.
Change Minute parameter to 0. You can set the cron for every three hours as: 0 */3 * * * your command here .. Save this answer.
Cron jobs are scheduled at recurring intervals, specified using a format based on unix-cron. You can define a schedule so that your job runs multiple times a day, or runs on specific days and months. (Although we no longer recommend its use, the legacy App Engine cron syntax is still supported for existing jobs.)
Run it every three days...
0 0 */3 * *
How about that?
If you want it to run on specific days of the month, like the 1st, 4th, 7th, etc... then you can just have a conditional in your script that checks for the current day of the month.
if (((date('j') - 1) % 3)) exit();
or, as @mario points out, you can use date('k') to get the day of the year instead of doing it based on the day of the month.
* * */3 * * that says, every minute of every hour on every three days. 0 0 */3 * * says at 00:00 (midnight) every three days.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With