我在 crontab 中有一行:
* * * * * date >> /home/pana/temperatures.txt; hddtemp /dev/sda >> /home/pana/temperatures.txt ;hddtemp /dev/sdb >> /home/pana/temperatures.txt ;sensors >> /home/pana/temperatures.txt ;printf "_________________________\n" >> /home/pana/temperatures.txt
我得到的只是日期,然后是 double,什么也没有,然后是传感器输出,然后是 printf。Hddtemp 不写入输出。该文件是 777,代码是通过插入的sudo crontab -e
。Syslog:
Jan 19 14:17:01 knedlik CRON[7099]: (CRON) info (No MTA installed, discarding output)
Jan 19 14:18:01 knedlik CRON[7108]: (root) CMD (date >> /home/pana/temperatures.txt; hddtemp /dev/sda >> /home/pana/temperatures.txt ;hddtemp /dev/sdb >> /home/pana/temperatures.txt ;sensors >> /home/pana/temperatures.txt ;printf "_________________________\n" >> /home/pana/temperatures.txt)
这可能是一些愚蠢的事情,但我看不出来!
答案1
正如 falconer 指出的那样 - 只需输入whereis
hddtemp 并添加脚本的完整路径。所以它看起来像:
* * * * * date >> /home/pana/temperatures.txt; /usr/sbin/hddtemp /dev/sda >> /home/pana/temperatures.txt ;/usr/sbin/hddtemp /dev/sdb >> /home/pana/temperatures.txt ;sensors -A >> /home/pana/temperatures.txt ;printf "_________________________\n" >> /home/pana/temperatures.txt