【问题标题】:Crontab every other hour and then the other hoursCrontab 每隔一个小时,然后是其他几个小时
【发布时间】:2016-09-14 20:57:31
【问题描述】:

我有每隔一小时运行一次的 crontab 脚本

2  */2  *   *   * cd /home/myuser/scripts && ./script.sh
4  */2  *   *   * cd /home/myuser/scripts && ./script2.sh
6  */2  *   *   * cd /home/myuser/scripts && ./script3.sh
8  */2  *   *   * cd /home/myuser/scripts && ./script4.sh
...

我想添加更多每隔一小时运行的脚本,而不是上述脚本运行的时间。所以上面的脚本都在各自的小时/分钟上运行让我们说在下午 1 点、下午 3 点......而我的新脚本在下午 2 点、下午 4 点运行......

【问题讨论】:

    标签: cron crontab cron-task


    【解决方案1】:

    我认为您的意思是希望新脚本每隔 odd 小时运行一次。如果是这样的话:

    2  1-23/2  *   *   * cd /home/myuser/scripts && ./script5.sh
    4  1-23/2  *   *   * cd /home/myuser/scripts && ./script6.sh
    6  1-23/2  *   *   * cd /home/myuser/scripts && ./script7.sh
    8  1-23/2  *   *   * cd /home/myuser/scripts && ./script8.sh
    ...
    

    所以script5.sh 将在script.sh 之前/之后恰好运行一小时,而script6.sh 将在script2.sh 之前/之后恰好一小时运行。

    参考:http://www.poweradded.net/2011/04/how-to-run-cron-jobs-on-evenodd-days.html

    如果我正确地解释了你的问题,我想以前有人问过这个问题:Specifying "all odd values" in crontab?

    【讨论】:

      猜你喜欢
      • 2017-05-08
      • 2018-09-23
      • 2023-03-28
      • 1970-01-01
      • 2021-04-23
      • 2012-02-13
      • 1970-01-01
      • 1970-01-01
      • 2012-01-27
      相关资源
      最近更新 更多