• TomyTang 在版块 Linux平台 中发起了话题 Openwrt Cron定时任务执行失败 1年, 6个月前

    进入openwrt 后台,创建一个计划任务定时执行脚本

    Cron 定时任务参数格式:

    f1 f2 f3 f4 f5 Program
    其中 f1 是表示分钟,f2 表示小时,f3 表示一个月份中的第几日,f4 表示月份,f5 表示一个星期中的第几天。Program 表示要执行的命令。
    0 03 * * * 表示每天的凌晨三点

    #每天早上6点更新执行脚本
    0 06 * * * bash /root/xxx/xxx.sh > /dev/null

    有可能会遇到软路由硬件重启后cron失效的情况,直接命令行编写。

    # vim /etc/crontabs/root

    如果直接用命令行写入root 仍然无法生效 ,解决定时脚本不生效的问题,在脚本前面加上

    source /etc/profile 来加载环境变量

    或者将脚本执行命令改为

    0 06 * * * bash /root/xxx/xxx.sh  &&  source /etc/profile > /dev/null

WirelessLink
Logo