【发布时间】:2018-11-30 11:59:10
【问题描述】:
我不在根里, 我在 crontab 中输入了以下命令:
*/1 * * * * /home/ajain/testscript.sh
文件 testscript.sh 有以下命令:
#!/bin/bash
echo "The script begins now"
ping -c 2 live.com
echo The script has been run on `date` >> /home/ajain/testscript.log
echo "The script ends now"
exit
crontab 没有给出结果,但是,以下命令在 testscript.log 文件中正确给出了结果,显示了 ping 日期。
bash testscript.sh
为什么 crontab 不工作?
【问题讨论】:
-
chmod 755 /home/ajain/testscript.sh 已经给出。
-
您没有收到来自 cron 的任何电子邮件吗?
-
你应该在 /home/ajain/testscript.log 中得到“脚本已在
date上运行”。 -
@WanmingZhang ,如果脚本是手动运行的,我会得到这个结果,但不是通过 crontab。
-
@TobySpeight 如何检查来自 cron 的电子邮件?我必须以 root 身份登录吗?