互联网服务crontab执行计划

crontab没有按计划执行

最近发现一个问题:我在crontab里面加了一个定时任务,每天早上8点钟跑一个脚本,生成一个文件,文件里面记录有脚本执行的时间,结果文件的生成时间和文件里面记录的时间比crontab里面设定的执行时间晚了有13个小时。

我已经反复检查crontab设置,没有问题;
检查主机时间也没有问题;
我也做了临时测试,在crontab里面设定一个时间(比主机时间晚一分钟),然后我等脚本执行,还是没有执行;

不知道该从哪里找原因了,各位有没有遇到相似的问题?

这个主机修改过时区,以前是CDT,现在是BEIST-8,修改时区前都是正常的,可能和修改时区有关,

当天时间
#date
Wed Aug  3 11:19:12 BEIST 2011

crontab内容
#crontab -l
30 4 * * * /usr/lpp/diagnostics/bin/run_ssa_link_speed 1>/dev/null 2>/dev/null
06 08 * * *  sh /home/zhangsan/checkout/check.sh


生成文件时间
$ ls -l
total 40
-rw-r--r--   1 root     system        15667 Aug 2 21:00 check.txt
-rwxrwxrwx   1 zhangsan    staff          1904 Jul 15 09:06 check.sh

每天早上8点钟跑的脚本(见下面的cron日志),(脚本手工运行正常,几秒钟就生成文件),放在crontab中执行生成的文件时间是当天晚上9点钟的(见上面一段生成文件时间)

crontab 日志
执行用户为root
#tail -n 1000 /var/adm/cron/log |more
root      : CMD (  sh /home/zhangsan/checkout/check.sh ) : PID ( 344186 ) : Tue Aug  2 08:00:00 2011
root      : CMD ( /usr/lpp/diagnostics/bin/run_ssa_healthcheck 1>/dev/null 2>/dev/null ) : PID ( 241734 ) : Tue Aug  2 08:00:
00 2011
Cron Job with pid: 241734 Successful
Cron Job with pid: 344186 Successful
.
.
.
root      : CMD (  sh /home/zhangsan/checkout/check.sh ) : PID ( 344186 ) : Tue Aug  2 08:00:00 2011(生成的文件时间是Aug  3 21:00:00)
root      : CMD ( /usr/lpp/diagnostics/bin/run_ssa_healthcheck 1>/dev/null 2>/dev/null ) : PID ( 241734 ) : Tue Aug  2 08:00:
00 2011
Cron Job with pid: 241734 Successful
Cron Job with pid: 344186 Successful

mail中没有相关日志
参与59

58同行回答

liu2006liu2006软件开发工程师crc
生成文本的时间:Thu Jul 21 21:00:00 BEIST 2011显示全部
生成文本的时间:Thu Jul 21 21:00:00 BEIST 2011收起
互联网服务 · 2011-07-22
浏览1687
热心冰块热心冰块项目经理浪潮INSPUR
你啥也不贴出来,就说没有问题,鬼知道哦。天生杀人猫 发表于 2011-7-22 15:43 很黄很暴力啊显示全部
你啥也不贴出来,就说没有问题,鬼知道哦。
天生杀人猫 发表于 2011-7-22 15:43


很黄很暴力啊收起
系统集成 · 2011-07-22
浏览1545
liu2006liu2006软件开发工程师crc
执行用户是root00 08 * * * sh /路径/check.sh显示全部
执行用户是root
00 08 * * * sh /路径/check.sh收起
互联网服务 · 2011-07-22
浏览1554
天生杀人猫天生杀人猫系统运维工程师联通系统集成有限公司
你啥也不贴出来,就说没有问题,鬼知道哦。显示全部
你啥也不贴出来,就说没有问题,鬼知道哦。收起
系统集成 · 2011-07-22
浏览1758
热心冰块热心冰块项目经理浪潮INSPUR
另外注意执行用户显示全部
另外注意执行用户收起
系统集成 · 2011-07-22
浏览1586
热心冰块热心冰块项目经理浪潮INSPUR
吧你写的命令贴出来,尝试吧复杂的命令套在脚本中执行,crontab中尽量写的简单显示全部
吧你写的命令贴出来,尝试吧复杂的命令套在脚本中执行,crontab中尽量写的简单收起
系统集成 · 2011-07-22
浏览1581
0_00_0数据库管理员ciso
查时区 啊显示全部
查时区 啊收起
政府机关 · 2011-07-22
浏览1798
adyleeadylee系统工程师TC
看來應該是 cron daemon 和 Time zone 間的問題.剛 man cron , 其中有說到 TZ 的問題 , 如下 :================================================================When the TZ environment variable is changed, either with the chtz command, a Web-based System Mana...显示全部
看來應該是 cron daemon 和 Time zone 間的問題.
剛 man cron , 其中有說到 TZ 的問題 , 如下 :
================================================================
When the TZ environment variable is changed, either with the chtz command, a Web-based System Manager application, or through SMIT, the cron daemon must be restarted. This enables the cron daemon to use the correct time zone and summer time change information for the new TZ environment variable.
Notes:
1 If you have a job scheduled to run between 1:00 AM and 2:00 AM on the day your time zone changes from daylight saving time to standard time your job will run twice.
2 If you have a job scheduled to run between 2:01 AM and 2:59 AM on the day your time zone changes from standard time to day light savings time your job will not run. You can change the time these jobs run, run them manually, or with until the following day to run them. The cron daemon does not need to be stopped. However, if changes are made to the TZ environment variable, kill the current cron daemon so that it automatically respawns and recognizes the new TZ setting.
================================================================
建議重新進行一次 TimeZone 設定程序後, 再直接Kill cron daemon , cron daemon 會自動respawns.收起
互联网服务 · 2011-07-22
浏览1639

提问者

liu2006
软件开发工程师crc
擅长领域: 服务器灾备信息集成平台

相关问题

问题状态

  • 发布时间:2011-07-22
  • 关注会员:1 人
  • 问题浏览:36075
  • 最近回答:2011-08-10
  • X社区推广