繁体   English   中英

crontab的sh在Centos中不起作用

[英]sh with crontab is not working in Centos

我正在用crontab测试一个sh脚本,该脚本只是创建一个文件

 #!/bin/bash
    PATH=$PATH:/bin:/usr/bin
    TMP_FILE=/home/hmm/AppFlatForRent/i_am_running
    touch "$TMP_FILE"

现在,我想在crontab上运行它,并使用了以下内容,但失败了

18 10 * * * sh /home/hmm/AppFlatForRent/hello.sh

还有这个

18 10 * * * usr/bin/sh /home/hmm/AppFlatForRent/hello.sh

我也在尝试这个

23 12 * * * /usr/bin/sh /home/hmm/AppFlatForRent/hello.sh
23 12 * * * sh /home/hmm/AppFlatForRent/hello1.sh
23 12 * * * /home/hmm/AppFlatForRent/hello2.sh

有人知道出什么问题吗?

解决方案:23 12 * * * sh /home/hmm/AppFlatForRent/hello1.sh

这可行!

从'/'开头的cron给出shell的完整路径:

18 10 * * * /usr/bin/sh /home/hmm/AppFlatForRent/hello.sh

或者,如果可以执行脚本,则直接退出该外壳程序并直接运行该脚本:

18 10 * * * /home/hmm/AppFlatForRent/hello.sh

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM