【发布时间】:2014-12-09 17:46:03
【问题描述】:
我正在使用 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
这行得通!
【问题讨论】:
-
$TMP_FILE是在哪里定义的?如果它在你自己的环境中,那么 cron 不知道它。 -
规范 shell 位置是
/bin/sh,而不是/usr/bin/sh。 -
我只需要创建一个文件来检查 shell 运行。我认为它没有定义:(
标签: linux shell cron sh crontab