设置了个定时任务,但是发现没有执行,查看日志如下 :
[root@xw-crm-dep d]# tail -f /var/log/cron
Aug 13 22:09:01 dep crond[1619]: (*system*) RELOAD (/etc/crontab)
Aug 13 22:09:01 dep crond[1619]: (sh) ERROR (getpwnam() failed)
搜了下,可能是没写用户名导致的。
准备加个用户名,发现里面的示例是有用户名user-name
的,加上后,果然就好了。
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
26 22 * * * root /bin/bash /command.sh
日志:
Aug 13 22:16:01 dep crond[1619]: (*system*) RELOAD (/etc/crontab)
Aug 13 22:16:01 dep CROND[8161]: (root) CMD ( /command.sh)
参考:https://blog.csdn.net/weixin_40583191/article/details/103469940