每三天 Cron 作业 [英] Cron job every three days
本文介绍了每三天 Cron 作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以每三天运行一次 cronjob?或者每月 10 次.
Is it possible to run a cronjob every three days? Or maybe 10 times/month.
推荐答案
每三天运行一次...
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屋!
查看全文