Cron工作每三天 [英] Cron job every three days

查看:1395
本文介绍了Cron工作每三天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以每三天运行一次 cronjob

Is it possible to run a cronjob every three days? Or maybe 10 times/month.

推荐答案

每三天运行一次...

Run it every three days...

0 0 */3 * *

如何?

如果你想要在一个月的特定日子里运行,例如第1,第4,第7等等,那么你只需要一个

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();

或者,如@mario指出,您可以使用date('k')获取日期而不是基于每月的日期。

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.

这篇关于Cron工作每三天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆