V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
guojing
V2EX  ›  问与答

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

  •  
  •   guojing · 2014-09-02 19:19:24 +08:00 · 20976 次点击
    这是一个创建于 3547 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我买了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 条回复    2014-09-02 23:05:43 +08:00
    jacy
        1
    jacy  
       2014-09-02 21:05:19 +08:00
    看看系统日志
    braveguywallce
        2
    braveguywallce  
       2014-09-02 21:09:40 +08:00
    建议你先阅读这段 wiki

    url=http://wiki.openwrt.org/zh-cn/doc/uci
    braveguywallce
        3
    braveguywallce  
       2014-09-02 21:13:39 +08:00
    /etc/init.d/crond start
    /etc/init.d/crond enable
    jasontse
        4
    jasontse  
       2014-09-02 21:19:45 +08:00 via iPad
    检查以下两个地方

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

    问号处可能不同
    em70
        5
    em70  
       2014-09-02 21:36:15 +08:00   ❤️ 1
    文件最后一定要加个空行,否则最后一行设置可能不执行,这次付出大量痛苦经历换来的经验.
    guojing
        6
    guojing  
    OP
       2014-09-02 23:05:43 +08:00   ❤️ 1
    谢谢各位,问题解决了。脚本#!/bin/sh这行去掉就没问题了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4483 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 09:49 · PVG 17:49 · LAX 02:49 · JFK 05:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.