特殊cron表达式:如何使异常?

编程入门 行业动态 更新时间:2024-10-28 06:35:10
本文介绍了特殊cron表达式:如何使异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我让cron每天凌晨3:50执行一个任务,除了一个星期二与这个月的第一天相符:

I made a cron to execute a task every tuesday at 3:50 AM - except a tuesday which coincides with the first day of the month:

50 3 * * 2 MyCommand

但我不知道

推荐答案

你可以在你的脚本中添加一个条件语句吗?我会这样做。

Can you put a conditional in your script? I would do that. And in your cron you can comment that it won't run on the first per your script directions

例如,在bash中你可以这样做:

As an example, in bash you can do this:

#!/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将是

So your cron would be

30 5 * * 2 /path/to/script # comment: script conditional in place to not run on the 1st

更多推荐

特殊cron表达式:如何使异常?

本文发布于:2023-11-24 08:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624503.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表达式   异常   cron

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!