Linux cron 常见问题

来源:互联网 发布:索罗斯做空人民币 知乎 编辑:程序博客网 时间:2024/05/18 03:49

软件包安装:

要使用cron服务,先要安装vixie-cron软件包和crontabs软件包,两个软件包作用如下:

vixie-cron软件包是cron的主程序。
crontabs软件包是用来安装、卸装、或列举用来驱动 cron 守护进程的表格的程序。

查看是否安装了cron软件包: rpm -qa|grep vixie-cron

查看是否安装了crontabs软件包:rpm -qa|grep crontabs

如果系统中有安装则会显示安装包的信息,没有的情况下可以用 rpm命令安装(yum命令也可以,无法执行yum的情况下就用rpm)

首先跳转到安装包所在的路径,执行如下命令

rpm -ivh vixie-cron*
rpm -ivh crontabs*

查看crond服务:

service crond status      查看crontab服务状态

service crond start //启动服务  

service crond stop //关闭服务  
service crond restart //重启服务  
service crond reload //重新载入配置

下面列一下我遇到的问题:

打开cron日志,显示    root (09/27-02:00:00-22654) CMD (run-parts /home/soft/Sync/cron/ftpSync)

这种情况下就是因为没有安装crontabs包所致

官网上对crontabs说明:

Content of RPM :
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
/etc/crontab
/usr/bin/run-parts
/usr/share/man/man4/crontabs.4.gz

所以这个包很重要,一定要安装

vixie-cron包则包含如下:

Content of RPM :
/etc/cron.d
/etc/logrotate.d/cron
/etc/rc.d/init.d/crond
/etc/rc.d/rc0.d/K60crond
/etc/rc.d/rc1.d/K60crond
/etc/rc.d/rc2.d/S40crond
/etc/rc.d/rc3.d/S40crond
/etc/rc.d/rc5.d/S40crond
/etc/rc.d/rc6.d/K60crond
/usr/bin/crontab
/usr/man/man1/crontab.1
/usr/man/man5/crontab.5
/usr/man/man8/cron.8
/usr/man/man8/crond.8
/usr/sbin/crond
/var/spool/cron

其他问题可参见博客:http://blog.csdn.net/jbgtwang/article/details/7995801

再附上crontab的两个安装包的下载路径:http://download.csdn.net/detail/u010520626/9640840

0 0
原创粉丝点击