如何指示cron每两周执行一次工作? [英] How to instruct cron to execute a job every second week?
本文介绍了如何指示cron每两周执行一次工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过 cron 运行一项作业,该作业将在每天的第二个星期二在给定时间执行.因为每个星期二都很容易:
I would like to run a job through cron that will be executed every second Tuesday at given time of day. For every Tuesday is easy:
0 6 * * Tue
但是如何在每个第二个星期二"(或者,如果您愿意 - 每两周一次)做到这一点?我不想在自己的脚本中实现任何逻辑,而是只在 cron 中保留定义.
But how to make it on "every second Tuesday" (or if you prefer - every second week)? I would not like to implement any logic in the script it self, but keep the definition only in cron.
推荐答案
怎么样,它确实将它保存在 crontab
中,即使它没有在前五个字段中精确定义:
How about this, it does keep it in the crontab
even if it isn't exactly defined in the first five fields:
0 6 * * Tue expr `date +\%W` \% 2 > /dev/null || /scripts/fortnightly.sh
这篇关于如何指示cron每两周执行一次工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文