【问题标题】:Cron help! Bi monthly jobs isn't working克朗帮忙!双月作业不起作用
【发布时间】:2017-01-09 15:34:43
【问题描述】:

我有一个 cronjob 来备份一些东西,但它似乎不起作用。您可以在这里看到它设置为每隔一个月的 1 日 0:00,它应该在今天早上运行。

0 0 1 1/2 * ./gitbackup.sh

这是日志 - 它没有运行!?

Aug 31 23:17:01 git-us CRON[22871]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug 31 23:20:01 git-us CRON[23349]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Aug 31 23:40:02 git-us CRON[26562]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Sep  1 00:00:01 git-us CRON[29878]: (smmsp) CMD (test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp)
Sep  1 00:00:01 git-us CRON[29879]: (bind) CMD ( /usr/sbin/ldap2bind)

有什么想法吗?

【问题讨论】:

    标签: linux scripting cron crontab


    【解决方案1】:

    根据 Cron 手册,指定你想要的每隔一个月:

    0 0 1 */2 * ./gitbackup.sh
    

    您也可以使用:

    0 0 1 2,4,6,8,10,12 * ./gitbackup.sh
    

    第二种形式的优点是你可以选择偶数月或奇数月,你的意图对读者来说很清楚。

    【讨论】:

    • 我会试一试并在每月 2 号寄出,我们明天就知道了。
    【解决方案2】:

    原来是因为我跑错了路....doh!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多