我有Ubuntu并且正在用户“alex”下运行。我有运行与crontab中却根发送我的电子邮件,它看起来像它没有作为结果正确运行下面的bash脚本不存在:Crontab没有真正以root身份运行时它应该是什么?
/dev/sda上 - Reallocated_Sector_Ct是
但是,如果我从webmin手动运行crontab作业,它没有问题。但是当它计划运行时,那是它失败的时候。也许它不是真的以root身份运行?
这里是我的代码:
#!/bin/bash
SMARTCHECK=`smartctl -a /dev/sda | grep "Reallocated_Sector_Ct" | awk 'NR==1 {print $10}'`
echo "/dev/sda - Reallocated_Sector_Ct is $SMARTCHECK"
if [ "$SMARTCHECK" != "0" ]; then
mail -s "Failing: /dev/sda" alex <<< "/dev/sda - Reallocated_Sector_Ct is $SMARTCHECK"
fi
谢谢!
你是如何设置它从根启动的?它在root的crontab中,没有密码的sudo,其他的? – Marat
首先猜测会是'smartctl'不在路径中吗?并尝试在命令行中使用'env -i'运行该命令,然后执行该命令吗? – Wrikken
如果不知道如何设置crontab,这是无法回答的。 –