标签:pos init pac ons logrotate min line smartd obs
[root@localhost ~]# chkconfig --list | grep "cron" crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]# cd /etc/init.d [root@localhost init.d]# ls abrt-ccpp certmonger halt mcelogd nfs-rdma quota_nld rpcsvcgssd sysstat abrtd cgconfig ip6tables mdmonitor ntpd rdisc rsyslog udev-post abrt-oops cgred iptables messagebus ntpdate rdma sandbox winbind acpid cpuspeed irqbalance netconsole numad restorecond saslauthd ypbind atd crond kdump netfs oddjobd rngd single auditd cups killall network portreserve rpcbind smartd autofs functions lvm2-lvmetad nfs postfix rpcgssd sshd blk-availability haldaemon lvm2-monitor nfslock psacct rpcidmapd sssd
[root@localhost init.d]# cd /etc/cron.d [root@localhost cron.d]# ls 0hourly raid-check sysstat [root@localhost cron.d]# cat 0hourly SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ 01 * * * * root run-parts /etc/cron.hourly
[root@localhost cron.d]# cd /etc/cron.hourly/
[root@localhost cron.hourly]# ls
0anacron mcelog.cron
[root@localhost cron.hourly]# cat 0anacron #!/bin/bash # Skip excecution unless the date has changed from the previous run if test -r /var/spool/anacron/cron.daily; then /var/spool/anacron/cron.daily文件中 存放cron 上次启动时间 如果当期的时间和文件中的时间一致,表示本次已经执行完毕,无需再次执行 day=`cat /var/spool/anacron/cron.daily` fi if [ `date +%Y%m%d` = "$day" ]; then exit 0; fi # Skip excecution unless AC powered if test -x /usr/bin/on_ac_power; then /usr/bin/on_ac_power &> /dev/null if test $? -eq 1; then exit 0 fi fi /usr/sbin/anacron -s 开机后的第一个 一分钟 (每个小时的第一分钟)开启 anacron 服务 anacron 由 cron 启动
[root@localhost cron]# cat /etc/anacrontab # /etc/anacrontab: configuration file for anacron anacron的配置文件 # See anacron(8) and anacrontab(5) for details. SHELL=/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # the maximal random delay added to the base delay of the jobs RANDOM_DELAY=45 随机延迟时间 0-45 分钟 # the jobs will be started during the following hours only START_HOURS_RANGE=3-22 执行时间 3点到 22点 几天执行一次 固定延迟几分钟 nice 执行的命令 #period in days delay in minutes job-identifier command 1 5 cron.daily nice run-parts /etc/cron.daily 7 25 cron.weekly nice run-parts /etc/cron.weekly @monthly 45 cron.monthly nice run-parts /etc/cron.monthly
[root@localhost cron.daily]# cat logrotate #!/bin/sh /usr/sbin/logrotate /etc/logrotate.conf 执行logrotate 转储命令,读 取/etc/logrotate.conf 主要配置文件(包含次要配置文件/etc/logrotate.d)按照 配置文 件的规则对日志进行转储 EXITVALUE=$? if [ $EXITVALUE != 0 ]; then /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]" fi exit 0
标签:pos init pac ons logrotate min line smartd obs
原文地址:https://www.cnblogs.com/cmgg/p/10262411.html