如何在linux中跳过周六和周日的cron作业?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9143965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:23:25  来源:igfitidea点击:

How to skip the cron job in saturday and sunday in linux?

linuxunixcrontab

提问by Rakesh Sabbani

Hi I want to setup a cron job in linux excluding saturday and sunday.

嗨,我想在 linux 中设置一个 cron 作业,周六和周日除外。

回答by SiegeX

Try this:

尝试这个:

# run every two hours at the top of the hour Monday through Friday
0 */2 * * mon-fri <command>

回答by Michel

Begin the line with 0 0 * * 1,2,3,4,5 <user> <command>. The first fields are minutes and hours. In this case the command will run at midnight. The stars mean: for every day of the month, and for every month. The 1 to 5 specify the days. monday to friday. 6=saturday 0=sunday.

以 开头0 0 * * 1,2,3,4,5 <user> <command>。第一个字段是分钟和小时。在这种情况下,命令将在午夜运行。星星的意思是:一个月的每一天,每个月。1 到 5 指定日期。星期一到星期五。6=星期六 0=星期日。