您的位置:首页 > 理论基础

MAC os x leopard 安装中的英语词汇和计算机技术

2009-07-29 19:01 459 查看
2013年3月9日 星期六

cron

1、查询是否安装软件包

[root@desktop4 ~]# rpm -e cronie-1.4.4-7.el6.x86_64 --nodeps

[root@desktop4 ~]# yum -y -d 0 install cronie-1.4.4-7.el6.x86_64

Warning: RPMDB altered outside of yum.

** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:

cronie-anacron-1.4.4-7.el6.x86_64 has missing requires of cronie = ('0', '1.4.4', '7.el6')

crontabs-1.10-33.el6.noarch has missing requires of /etc/cron.d

sysstat-9.0.4-18.el6.x86_64 has missing requires of /etc/cron.d

[root@desktop4 ~]#

2、查询服务是否开启

[root@desktop4 ~]# service crond status

crond is stopped

[root@desktop4 ~]# service crond start

Starting crond: [ OK ]

[root@desktop4 ~]# service crond status

crond (pid 8228) is running...

[root@desktop4 ~]#

3、设置服务永久生效

[root@desktop4 ~]# chkconfig --list cron

error reading information on service cron: No such file or directory

[root@desktop4 ~]# chkconfig --list crond

crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@desktop4 ~]# chkconfig --level 35 crond off

[root@desktop4 ~]# chkconfig --list crond

crond 0:off 1:off 2:on 3:off 4:on 5:off 6:off

[root@desktop4 ~]# chkconfig --level 35 crond on

[root@desktop4 ~]# chkconfig --list crond

crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off

4、查看配置文件

[root@desktop4 ~]# cat /etc/crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/

# 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

5、管理cron数据文件

(1)设置任务

[root@desktop4 ~]# crontab -e

no crontab for root - using an empty one

crontab: installing new crontab

(2)查询设置情况

[root@desktop4 ~]# crontab -l

50 07 * * * /sbin/service sshd start

50 22 * * * /sbin/service sshd stop

* * */5 * * /bin/rm -rf /var/ftp/pub/*

30 7 * * 6 /sbin/service httpd restart

30 17 * * 1,3,5 /bin/tar jcvf httpdconf.tar.bz2 /etc/httpd

[root@desktop4 ~]#

(3)为其他用户设置计划任务

[root@desktop4 ~]# crontab -e -u chenglong

crontab: installing new crontab

[root@desktop4 ~]#

(4)查询设置情况

[root@desktop4 ~]# crontab -l -u chenglong

55 23 * * 0 /bin/cp /etc/passwd /home/chenglong/pwd.txt

[root@desktop4 ~]#

[root@desktop4 ~]# ls -l /var/spool/cron/chenglong

-rw-------. 1 root root 56 Mar 10 09:35 /var/spool/cron/chenglong

[root@desktop4 ~]#

(5)删除用户计划任务

[root@desktop4 ~]# crontab -r -u chenglong

[root@desktop4 ~]# crontab -l -u chenglong

no crontab for chenglong

[root@desktop4 ~]#

[root@desktop4 cron]# cat /var/spool/cron/chenglong

cat: /var/spool/cron/chenglong: No such file or directory

[root@desktop4 cron]#

(6)删除系统(超级管理员的)计划任务

[root@desktop4 ~]# crontab -l

50 07 * * * /sbin/service sshd start

50 22 * * * /sbin/service sshd stop

* * */5 * * /bin/rm -rf /var/ftp/pub/*

30 7 * * 6 /sbin/service httpd restart

30 17 * * 1,3,5 /bin/tar jcvf httpdconf.tar.bz2 /etc/httpd

[root@desktop4 ~]#

[root@desktop4 ~]# crontab -r

[root@desktop4 ~]# crontab -l

no crontab for root

[root@desktop4 ~]#

[root@desktop4 ~]# vim /etc/cron.weekly/

[root@desktop4 ~]# vim /etc/cron.hourly

[root@desktop4 ~]# vim /etc/cron.daily

[root@desktop4 ~]# vim /etc/cron.monthly/

[root@desktop4 ~]#

本文出自 “・” 博客,请务必保留此出处http://fengzhao001.blog.51cto.com/6516175/1156393
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: