crontab定时脚本常见报错

1、crontab定制后台定时备份任务时报出“bad minute”及“errors in crontab file, can't install”错误,“Do you want to retry the same edit?  Enter Y or N”

根本原因crontab文件中时间格式定义不正确导致的,需要严格按照下面格式书写。

0 0 * * *  /data/date/date.sh
分 时 日 月 周(0-6)【用户】 绝对路径脚本

#####
当用户是root时,需省略,否者会出现如下报错
/bin/sh: root: command not found

2、crontab定时任务不执行,并且没有收到错误信息邮件

A:查看日志/var/log/cron显示如下

CROND[15777]: (root) MAIL (mailed 33 bytes of output but got status 0x0043#012)

B:使用sendmail 命令

endmail: warning: valid_hostname: numeric hostname: 7

sendmail: fatal: file /etc/postfix/main.cf: parameter mydomain: bad parameter value: 7

原因:sendmail没有安装

3、重新执行脚本

/bin/sh: root: command not found

原因:root需省略

 参考博客:

https://blog.csdn.net/weixin_41399020/article/details/83927414

https://blog.csdn.net/sd4493091/article/details/83345661

https://blog.csdn.net/default7/article/details/40214305?locationNum=4

猜你喜欢

转载自blog.csdn.net/l_liangkk/article/details/105062791