查看crond进程是否启动
[root@kafka-4 feng]# ps aux|grep crond root 818 0.0 0.0 126388 1628 ? Ss 01:35 0:00 /usr/sbin/crond -n root 23676 0.0 0.0 112828 988 pts/1 S+ 20:20 0:00 grep --color=auto crond2、
时间间接: 最短时间间隔 1分钟
最短时间间接: 1秒 --》shell、python等
crond在执行脚本的时候,到PATH里去找要执行的命令
[root@kafka-4 feng]# service crond stop Redirecting to /bin/systemctl stop crond.service [root@kafka-4 feng]# ps aux|grep crond root 23706 0.0 0.0 112824 984 pts/1 S+ 20:20 0:00 grep --color=auto crond [root@kafka-4 feng]# service crond start Redirecting to /bin/systemctl start crond.service4、crontab的基本语法
1、 vim /etc/crontab 配置文件
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin --》crond在执行脚本的时候,到PATH里去找要执行的命令
#脚本里的命令尽量使用绝对路径,不要使用相对路径
MAILTO=root
# 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
2、创建一个计划任务
[root@kafka-4 feng]# crontab -e 建立一个计划任务 30 2 * * * bash /feng/backup_log.sh
3、查看计划任务
[root@kafka-4 feng]# crontab -l 30 2 * * * bash /feng/backup_log.sh
4、取消计划任务,加注释
[smallchen@kafka-4 ~]$ crontab -l #*/1 * * * * mkdir -p ~/sc$RANDOM5、查看有哪些人创建了计划任务
[root@kafka-4 feng]# cd /var/spool/cron/
6、查看Linux里有哪些自带的计划任务[root@kafka-4 cron]# cd /etc/cron(按两下Tab键补齐) cron.d/ cron.daily/ cron.deny cron.hourly/ cron.monthly/ crontab cron.weekly/ [root@kafka-4 cron]# [root@kafka-4 cron.d]# cd /etc/cron.daily/ [root@kafka-4 cron.daily]# ls logrotate man-db.cron [root@kafka-4 cron.daily]# [root@kafka-4 cron.daily]# cd /etc/cron.hourly/ [root@kafka-4 cron.hourly]# ls 0anacron [root@kafka-4 cron.hourly]# /etc/cron.monthly/ /etc/cron.weekly/



