shine_wang 发表于 2008-12-18 11:14

【求助】 [RedHat] AS4.6的cron任务怎么没有执行?

AS4.6的cron任务怎么没有执行?

crontab -l可以看到任务,但是就是没有执行,怎么回事呢?
查看cron日志就看到这些信息
cron服务已经启动了
# tail -50 /var/log/cron
Dec 17 09:50:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg -
-lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 17 09:50:01 ha2 crond: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 17 09:55:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg -
-lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 17 10:00:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg -
-lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 17 10:00:01 ha2 crond: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 17 10:01:01 ha2 crond: (root) CMD (run-parts /etc/cron.hourly)
Dec 17 10:05:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg -
-lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 17 10:10:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg -
-lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 17 10:10:02 ha2 crond: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 17 10:15:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg --l
ock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 17 10:20:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg --
lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 17 10:20:01 ha2 crond: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 17 10:25:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg --
lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)


以前我一般是先vi /home/xx/xx.cron
然后crontab /home/xx/xx.cron
一直没有问题
可能这个xx.cron文件有次被我下载到win中,用记事本替换了字符,造成问题?

现在重新在linux下vi /home/xx/xx.cron,还是不行
# tail -50 /var/log/cron
Dec 18 08:30:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg -
-lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 18 08:30:01 ha2 crond: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 18 08:35:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg -
-lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 18 08:40:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg -
-lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 18 08:40:01 ha2 crond: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 18 08:45:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg -
-lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 18 08:50:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg --l
ock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 18 08:50:01 ha2 crond: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 18 08:55:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg --
lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 18 09:00:01 ha2 crond: (root) CMD (/usr/bin/mrtg /etc/mrtg/mrtg.cfg --
lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok)
Dec 18 09:00:01 ha2 crond: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 18 09:01:01 ha2 crond: (root) CMD (run-parts /etc/cron.hourly)

Roamvalley 发表于 2008-12-18 12:38

你添加一两个其它命令到cron中,看看是不是mrtg出了问题,而不是cron出了问题。

shine_wang 发表于 2008-12-18 13:50

cron的命令都是以前es3可以用的,手工也可以执行的。
命令里面没有mrtg,
xx.cron:

01 02 * * * /app/mfgpro/eb21/client.auto
41 02 * * * /app/mfgpro/eb21/stop.test
42 02 * * * /app/mfgpro/eb21/stop.Production
43 02 * * * /app/mfgpro/eb21/stop.Training
44 02 * * * /app/mfgpro/eb21/stop.Demonstration
45 02 * * * /app/mfgpro/eb21/stop.Compile
46 02 * * * /app/mfgpro/eb21/stop.daktest
#53 02 * * * /app/progress/91e/bin/procopy /data/prod/mfgprod.db /databk/test/mfgtest.db
48 02 * * * cp -rf /data/prod/*pro* /svck005/rh2/prod
15 04 * * * cp -rf /app/progress/91e /svck007/rh2

[ Edited byshine_wang on 2008-12-18 13:56 ]

shine_wang 发表于 2008-12-18 14:23

之前可以执行,有次运行crontab -r关闭任务,后来再次crontab xx.cron之后就出现上面症状

liu_yunsheng 发表于 2008-12-18 15:16

那你重启一下crond的服务试试。

shine_wang 发表于 2008-12-18 17:14

回复 #5 liu_yunsheng 的帖子

重启过了,还是不行,已经联络红帽客服,看能否有结果

Roamvalley 发表于 2008-12-18 18:39

我觉得可能是你现在的cron的配置文件路径不再是/home/xx/xx.cron了。

shine_wang 发表于 2008-12-19 09:47

昨天联系红帽客服,说可能是我在WIN下替换了rh2.cron,导致里面有不可识别字符。用dos2unix转换后,执行OK
还有log里面的那些cron中的记录没有什么问题的

#dos2unix rh2.cron
dos2unix: converting file rh2.cron to UNIX format ...
# crontab rh2.cron
# /sbin/service crond restart
Stopping crond:                                          
Starting crond:

今天看任务已经成功执行了
页: [1]
查看完整版本: 【求助】 [RedHat] AS4.6的cron任务怎么没有执行?