日期:2014-05-16  浏览次数:20619 次

关于crontab的小问题
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
#   run-parts
01   *   *   *   *   root   run-parts   /etc/cron.hourly
02   4   *   *   *   root   run-parts   /etc/cron.daily
22   4   *   *   0   root   run-parts   /etc/cron.weekly
42   4   1   *   *   root   run-parts   /etc/cron.monthly
*/5   8-19   *   *   *   root   /home/boman/test.sh
上面内容为crontab内容
/home/boman/test.sh内容如下
tar   czvf   "test`date   +%Y%m%d`.tar "   /home/boman/testdata
现在情况是单独运行test.sh,可以正常得出结果
但crontab根本不会运行??

------解决方案--------------------
路径吧
这样会给你把生成的文件放到/root目录的
------解决方案--------------------
*/5 8-19 * * * /home/boman/test.sh

去掉root


------解决方案--------------------
#crontab -u root -e
*/5 8-19 * * * /home/boman/test.sh

这样试试吧