gpt4 book ai didi

linux - 特殊的 cron 表达式 : how to make an exception?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:57:30 24 4
gpt4 key购买 nike

我创建了一个 cron 来在每个星期二凌晨 3: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

关于linux - 特殊的 cron 表达式 : how to make an exception?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24508099/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com