[root@fanhua ~]# systemctl status crond.service
[root@fanhua ~]# ps aux |grep crond
root 550 0.0 0.0 126300 1648 ? Ss 10:05 0:00 /usr/sbin/crond -n
crond进程每分钟会处理一次计划任务
存储位置:
[root@fanhua ~]# ls /var/spool/cron/
root
管理方式:
crontab -l List the jobs for the current user. //列出当前用户的计划任务
crontab -r Remove all jobs for the current users. //删除当前用户所有的计划任务
crontab -e Edit jobs for the current user. //编辑当前用户的计划任务
语法格式 Job format:
Minutes Hours Day-of-Month Month Day-of-Week Command
分钟 小时 日 月 周 执行的命令
#crontab -e //当前用户编写计划任务
#vim /home/youngfit.sh
touch /opt/a.txt
chmod +x /op
每天6:00执行
0 6 * * * /home/youngfit.sh
每天8:40执行
40 8 * * * /home/youngfit.sh
每周六凌晨4:00执行
0 4 * * 6 /home/youngfit.sh
每周六凌晨4:05执行
5 4 * * 6 /home/youngfit.sh
每周六凌晨5:00执行
0 5 * * 6 /home/youngfit.sh
每周一到周五9:30
30 9 * * 1-5 /home/fanhua.sh
每周一到周五8:00,每周一到周五9:00
0 8,9 * * 1-5 /home/fanhua.sh
每周六23:59
59 23 * * 6 /home/fanhua.sh
每天0:30
30 0 * * * /home/fanhua.sh
crontab -l //列出计划任务
00 00 * * * /home/fanhua.sh //每天凌晨
00 02 * * * ls //每天2:00整
00 02 1 * * ls //每月1号2:00整
00 02 14 2 * ls //每年2月14号2:00整
00 02 * * 0 ls //每周日2:00整
周日为0
00 02 * 6 5 ls //每年6月的周五2:00整/
00 02 * * * ls //每天2:00整
*/5 * * * * ls //每隔5分钟
00 02 1,5,8ls //每月1,5,8号的2:00整
00 02 1-8 * * ls //每月1到8号的2:00整
使用者权限文件:
文件:
/etc/cron.deny
说明:
该文件中所列用户不允许使用crontab命令
文件:
/etc/cron.allow
说明:
该文件中所列用户允许使用crontab命令