目标:
5 * * * * /app/tasks/time.sh
0,15,30,45 * * * * /app/tasks/delactivecalls.sh
0 5 * * * /app/tasks/delaaalog.sh
10 * * * * /app/tasks/rmarch.sh
0 4 * * * /app/tasks/backupaaalog.sh
参考天津百信
5 * * * * /app/tasks/time.sh
0,15,30,45 * * * * /app/tasks/delactivecalls.sh
0 5 * * * /app/tasks/delaaalog.sh
10 * * * * /app/tasks/rmarch.sh
0 4 * * * /app/tasks/backupaaalog.sh
30 1 * * * /app/tasks/expdata.sh >>/dev/null
一、crond服务是否随系统启动
1.1、
# service crond status
crond (pid 2117) 正在运行...
# ll /etc/rc.d/init.d/crond
-rwxr-xr-x. 1 root root 2826 11月 23 20:43 /etc/rc.d/init.d/crond
# ll /etc/rc1.d/K61oracle
# ll /etc/rc3.d/S99oracle
##ntsysv的作用就是把目录/etc/init.d的文件在相应运行级别的目录创建或删除链接文件;使用空格选择或者取消,使用*表示自动启动服务
# ntsysv
ntsysv 1.3.49.3 - (C) 2000-2001 Red Hat, Inc.
+------------+ 服务 +------------+
| |
| 您想自动启动哪些服务? |
| |
| [ ] NetworkManager |
| [*] abrt-ccpp |
| [*] abrtd a |
| [*] acpid a |
| [*] atd a |
| [*] auditd a |
| [*] autofs a |
| [*] blk-availability a |
| [*] bluetooth a |
| [*] certmonger a |
| [*] cgconfig a |
| [ ] cgred a |
| [*] cpuspeed a |
| [*] crond a |
| [*] cups a |
| [ ] dnsmasq a |
| [ ] ebtables a |
| [ ] firstboot a |
| [*] haldaemon a |
| [ ] htcacheclean a |
| [ ] httpd a |
| [*] hypervkvpd a |
| [*] ip6tables |
| |
| +------+ +------+ |
| | 确定 | | 取消 | |
| +------+ +------+ |
| |
| |
+--------------------------------+
# ps -ef|grep sqlplus|grep -v "grep"|wc -l ##逆向匹配
1.2、创建crontab
]# cd /var/spool/cron
# ll
总用量 0
# cd ~
# vi rootcron
#5 * * * * /app/tasks/time.sh
0,15,30,45 * * * * /app/tasks/delactivecalls.sh
0 5 * * * /app/tasks/delaaalog.sh
10 * * * * /app/tasks/rmarch.sh
0 4 * * * /app/tasks/backupaaalog.sh
30 1 * * * /app/tasks/expdata.sh >>/dev/null
1.2、查看脚本是否正确
1.3、
# cd /var/spool/cron/
# ll
总用量 0
# crontab ~/rootcron #把任意规定格式的文件提交给cron进程
# crontab -l
#5 * * * * /app/tasks/time.sh
0,15,30,45 * * * * /app/tasks/delactivecalls.sh
0 5 * * * /app/tasks/delaaalog.sh
10 * * * * /app/tasks/rmarch.sh
0 4 * * * /app/tasks/backupaaalog.sh
30 1 * * * /app/tasks/expdata.sh >>/dev/null
# cd /var/spool/cron/
# ll
总用量 4
-rw------- 1 root root 226 5月 9 10:13 root