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

shell文件可以手工执行,放到cron里就报错,这是怎么回事?
系统是debian6.0

shell文件:
/home/shell/auto.sh

如果直接执行这个文件,一切正常

但是我把它放到/etc/crontab文件中最后一行每天定时执行
29 08 * * * * root /home/shell/auto.sh



查看日志显示:
May 20 08:29:01 myserver cron[3543]: Error: bad username; while reading /etc/crontab
May 20 08:29:01 myserver /usr/sbin/cron[3543]: (*system*) ERROR (Syntax error, this crontab file will be ignored)


我尝试过使用crontab -e添加任务也是有这个错误日志

------解决方案--------------------
root去掉。
------解决方案--------------------
vim /var/log/cron

check the log file and your mailbox
------解决方案--------------------
试过这个吗?

29 08 * * * root /home/shell/auto.sh

另外,修改完crondtab文件后,需要重启crond任务 


/etc/init.d/cron restart
------解决方案--------------------
29 08 * * * (这里应该是一个tab制表符,不是空格) sh /home/shell/auto.sh

------解决方案--------------------
29 08 * * * (这里应该是一个tab制表符,不是空格) sh /home/shell/auto.sh

------解决方案--------------------
将 auto.sh 中的命令改为绝对路径试试?
------解决方案--------------------
换到其他目录下,执行一下这个脚本,看看是不是相对路径与绝对路径的问题。
不过看提示,是Syntax error,格式问题,lz参考上面几位的吧