centos 7 配置定时任务crontab
修改crontab配置
vi /etc/crontab
crontab语法
* * * * * Command_to_execute
| | | | |
| | | | Day of the Week ( 0 - 6 ) ( Sunday = 0 )
| | | |
| | | Month ( 1 - 12 )
| | |
| | Day of Month ( 1 - 31 )
| |
| Hour ( 0 - 23 )
|
Min ( 0 - 59 )
启动、重启、停止crond服务
sudo service crond start/restart/stop
查看crond的日志
cat /var/log/cron
常见问题
1.重启crond出现错误:(CRON) DEATH (can't lock /var/run/crond.pid, otherpid may be 97764): 资源暂时不可用
直接kill -9 [pid] 把现有的crond进程干掉,然后 sudo service crond restart
https://www.cyberciti.biz/faq/howto-linux-unix-start-restart-cron/