guojing
V2EX  ›  问与答

openwrt crontab 定时执行任务没作用,求原因?

  •  
  •   guojing · Sep 2, 2014 · 21777 views
    This topic created in 4314 days ago, the information mentioned may be changed or developed.
    我买了wndr3700V4刷openwrt,写个脚本,想让crontab定时执行这个脚本,没运行。脚本如下:
    #!/bin/sh
    top -n 1| head -n 8 >> /root/history.txt
    我直接运行可用。然后在luci计划任务添加*/1 * * * * /root/cron_ss
    但是/root/history.txt一直没生成,应该是没运行。
    我cronttab服务有开启。/etc/init.d/cron enable ,/etc/init.d/cron start都执行过。但都没作用,求解
    我刷的是http://www.blazebox.homeip.net/~diffie/openwrt/barrier_breaker/这个,版本r42323
    6 replies    2014-09-02 23:05:43 +08:00
    jacy
        1
    jacy  
       Sep 2, 2014
    看看系统日志
    braveguywallce
        2
    braveguywallce  
       Sep 2, 2014
    建议你先阅读这段 wiki

    url=http://wiki.openwrt.org/zh-cn/doc/uci
    braveguywallce
        3
    braveguywallce  
       Sep 2, 2014
    /etc/init.d/crond start
    /etc/init.d/crond enable
    jasontse
        4
    jasontse  
       Sep 2, 2014 via iPad
    检查以下两个地方

    # ps | grep crond
    ? root ? S /usr/sbin/crond -f -c /etc/crontabs -l 8
    # cat /etc/crontabs/root
    ? ? * * * ??????

    问号处可能不同
    em70
        5
    em70  
       Sep 2, 2014   ❤️ 1
    文件最后一定要加个空行,否则最后一行设置可能不执行,这次付出大量痛苦经历换来的经验.
    guojing
        6
    guojing  
    OP
       Sep 2, 2014   ❤️ 1
    谢谢各位,问题解决了。脚本#!/bin/sh这行去掉就没问题了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5450 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 07:08 · PVG 15:08 · LAX 00:08 · JFK 03:08
    ♥ Do have faith in what you're doing.