Common errors in crontab timing scripts

1. "Bad minute" and "errors in crontab file, can't install" errors are reported when crontab customizes the background timing backup task, "Do you want to retry the same edit? Enter Y or N"

The root cause is that the time format definition in the crontab file is incorrect, and it needs to be written in strict accordance with the following format.

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

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

2. The crontab timing task is not executed, and no error message email is received

A: View the log /var/log/cron as shown below

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

B: Use the sendmail command

endmail: warning: valid_hostname: numeric hostname: 7

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

Reason: sendmail is not installed

3. Re-execute the script

/bin/sh: root: command not found

Reason: root needs to be omitted

 

 

 Reference blog:

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

Guess you like

Origin blog.csdn.net/l_liangkk/article/details/105062791