以下 cron 表达式 cron(0 14 ? * MON-FRI *)
基本上在周一至周五下午 4:00 运行。
我想知道是否可以修改表达式,以便我可以在每周一至周五的凌晨 4:00 和下午 4:00 运行一些东西。
答案 0 :(得分:2)
使用此crontab
行运行command_name
在4:00和16:00(上午04时和下午4点)星期一至星期五:
0 4,16 * * 1-5 command_name
The time and date fields are:
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sunday, or use names)
答案 1 :(得分:0)
您的 Cron 工作描述看起来与一般的 crontab 不同。但是为了让您了解如何实现您的目标:
crontab -e
* 4 * * 1-5 /usr/bin/...# Your command goes here 04:00 am.
* 16 * * 1-5 /usr/bin/...# Your command goes here 04:00 pm.
答案 2 :(得分:-1)
下午4点(16点):0 16 * * MON-FRI
见crontab guru
“在16:00每一天的一周,从周一到周五。”
4AM和4 PM(4:00&16:00):0 4,16 * * MON-FRI
见crontab guru
“在每一天的一周,从周一到周五分钟0过去一小时4和16。”