zoukankan      html  css  js  c++  java
  • 关于cron的一个答疑

    原文从网上检索的

    主要是怎么调试, 而且因为有些环境变量在cron里是没有的,所以应该怎么写之类的。

    Noah wrote:

    > I just rebuilt a new 5.5 server and I am finding root's crontab entries
    > are not being executed.  any body got some clues about how I can
    > troubleshoot this issue so my cron entries are bring executed.

    Verify that root's crontab does anything at all by running a simple
    command every minute.  Eg. use 'crontab -u root -e' to add this
    line to the root crontab:

        */1 * * * * /usr/bin/touch /tmp/foo

    Then if you do 'ls -l /tmp/foo' you should see the timestamp changing
    every minute.  Remember to remove this line once you're done testing.

    If it doesn't, check that cron is enabled and running.  It is enabled
    by default in /etc/defaults/rc.conf.

    Examine /var/log/cron -- everything cron tries to run should be logged
    there.

    However, I suspect that the problem is the standard gotcha when using
    cron.  Scripts run from cron get a very minimal environment.  In
    particular you *will* need to set the PATH explicitly at the top of
    your script. Something like this generally suffices:

        PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/sbin:/usr/sbin:/usr/local/sbin
        export PATH

    Or else use fully qualified paths for any programs you call from the
    script.

    This is the primary cause of programs that work fine under test when
    run from your login account but that do not work when run from cron.

            Cheers,

            Matthew

  • 相关阅读:
    圣诞快乐有感
    今天填补了尹大神的一个小瑕疵 被他戏称接锅侠 有感
    统计js数组中奇数元素的个数
    PHP实现一致性哈希算法
    寻找一组数的最大值并统计出现次数
    得知尹大神最后一天在岗位工作明天即将离开有感
    小物件之checkbox复选框
    处理特殊格式的GET传参
    vim分屏
    【学习笔记】Docker基础
  • 原文地址:https://www.cnblogs.com/johnsonshu/p/2569376.html
Copyright © 2011-2022 走看看