我在每周二凌晨3点50分做了一个cron执行任务 – 除了与本月的第一天一致的星期二:
50 3 * * 2 MyCommand
但我不知道如何将我的exception转换成cron语法,任何提示?
你可以在脚本中添加一个条件吗? 我会这样做的。 而在你的cron中,你可以评论它不会在第一个脚本方向上运行
举个例子,在bash中你可以这样做:
#!/bin/bash dayofmonth=`date +"%d"` if [ $dayofmonth == "01" ]; then # do not run, exit exit fi # otherwise go on echo "it is not the first"
所以你的cron会
30 5 * * 2 /path/to/script # comment: script conditional in place to not run on the 1st
您可以将“每月的日期”字段设置为2-31,有效地排除第一天。 这应该做到这一点:
50 3 2-31 * 2 MyCommand