启停crontab服务
service crond start
service crond stop
service crond restart
service crond reload
service crond status
查看定时服务
crontab -l
编辑定时服务
crontab -e
每二分钟执行一次
*/2 * * * * /root/script/job_run_minutes_5.sh
每小时第5分钟执行一次
5 */1 * * * /root/script/job_run_hour_1.sh
每天8 点20执行一次
20 8 * * * /root/script/job_run_day_1.sh
每天8:30, 12:30执行
30 8,12 * * * /root/script/job_run_day_1.sh
docker中使用crontab:
1.通过yum安装crontab
2.将/etc/pam.d/crond文件中的required改为sufficient
more /etc/pam.d/crond
#
# The PAM configuration file for the cron daemon
#
#
# No PAM authentication called, auth modules not needed
account sufficient pam_access.so
account include password-auth
session sufficient pam_loginuid.so
session include password-auth
auth include password-auth
3.重启crond服务