TShopping

 找回密碼
 註冊
搜索
查看: 3533|回復: 4
打印 上一主題 下一主題

[問題] crontab「errors in crontab file, can't install」錯誤處理

[複製鏈接]
跳轉到指定樓層
1#
發表於 2011-9-16 17:23:52 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
 
Push to Facebook

今天有朋友提到,在使用crontab定制後台定時備份任務時報出「bad Hour」及「errors in crontab file, can't install」錯誤
經確認,根本原因是crontab文件中時間格式定義不正確導致的。
簡單記錄一下這個問題,同時確認一下crontab中時間格式的規範,供參考。

1.具體報錯信息如下
ora10g@secDB /home/oracle$ crontab -e
no crontab for oracle - using an empty one
crontab: installing new crontab
"/tmp/crontab.XXXXcz4Lql":1: bad hour
errors in crontab file, can't install.
Do you want to retry the same edit?
Enter Y or N
Do you want to retry the same edit?
Enter Y or N
Do you want to retry the same edit?
Enter Y or N
Do you want to retry the same edit?
Enter Y or N
Do you want to retry the same edit?
Enter Y or N
Do you want to retry the same edit?
Enter Y or N
Do you want to retry the same edit? N
crontab: edits left in /tmp/crontab.XXXXcz4Lql

2.crontab時間格式內容
*    *    *    *    *    command
M    H    D    m    d    command
分   時   日   月   周   命令
第1列表示分鐘1~59 每分鐘用*或者 */1表示
第2列表示小時1~23(0表示0點)
第3列表示日期1~31
第4列表示月份1~12
第5列標識號星期0~6(0表示星期天)
第6列要運行的命令或腳本內容

如果能掌握這個crontab的時間格式的定義,基本上就會避免出現「bad minute」錯誤。

3.正確格式樣例一則
ora10g@secDB /home/oracle$ crontab -e
0 22 * * 0-6 /db_backup/dpump_dir/expdp.sh 1>>/db_backup/dpump_dir/expdp.log 2>&1
~
~

這是一個比較常見的使用EXPDP命令定時備份數據庫的例子。
「/db_backup/dpump_dir/expdp.sh」腳本將在每天晚上10點自動運行,同時將運行的日誌寫入到「/db_backup/dpump_dir/expdp.log」文件中。

4.如果仍然解決不了問題,可以考慮重新啟動crond服務
注意需要使用root用戶完成服務的重啟。
ora10g@secDB /home/oracle$ su - root
Password:

[root@secDB ~]# /etc/rc.d/init.d/crond restart
Stopping crond:                                            [  OK  ]
Starting crond:                                            [  OK  ]

5.小結
如果能夠按照規則和操作規範完成維護操作,出錯的概率將會大大的降低,因此平時指定好規範文檔非常的重要。




 

臉書網友討論
2#
發表於 2013-11-10 00:57:28 | 只看該作者
支持一下吧  

版主招募中

3#
發表於 2013-11-10 00:57:28 | 只看該作者
頂你一下,好帖要頂!  


4#
發表於 2013-11-10 00:57:28 | 只看該作者
HOHO~~~~~~  


5#
發表於 2013-12-20 09:37:22 | 只看該作者
爱死你了,这么好的帖子要顶的


*滑块验证:
您需要登錄後才可以回帖 登錄 | 註冊 |

本版積分規則



Archiver|手機版|小黑屋|免責聲明|TShopping

GMT+8, 2024-5-10 23:41 , Processed in 0.051578 second(s), 18 queries .

本論壇言論純屬發表者個人意見,與 TShopping綜合論壇 立場無關 如有意見侵犯了您的權益 請寫信聯絡我們。

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表