我做了一个cron来执行每周二上午03点50分一个任务 - 除了星期二与当月的第一天恰逢:
50 3 * * 2 MyCommand
但我不知道我怎么可以在我的异常转换成cron的语法,任何提示?
我做了一个cron来执行每周二上午03点50分一个任务 - 除了星期二与当月的第一天恰逢:
50 3 * * 2 MyCommand
但我不知道我怎么可以在我的异常转换成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