crontab「errors in crontab file, can't install」錯誤處理
今天有朋友提到,在使用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:
# /etc/rc.d/init.d/crond restart
Stopping crond:
Starting crond:
5.小結
如果能夠按照規則和操作規範完成維護操作,出錯的概率將會大大的降低,因此平時指定好規範文檔非常的重要。
支持一下吧 頂你一下,好帖要頂! HOHO~~~~~~ 爱死你了,这么好的帖子要顶的
頁:
[1]