2013-02-01 55 views
1

我有一個腳本,可以隨時運行。所以/etc/cron.daily似乎是一個簡單的解決方案。Cronjob cron.daily不運行(debian)

但現在我得到了問題,cronjob將不會運行該腳本。這似乎是cronjob不會運行任何日常工作。

所以我試圖把它放到cron.hourly,一切正常。 但我不想每小時運行備份腳本。

/etc/init.d/cron start|stop工作沒有錯誤。

/etc/crontab貌似默認:

m h dom mon dow user command 
17 * * * * root cd/&& run-parts --report /etc/cron.hourly 
25 6 * * * root test -x /usr/sbin/anacron || (cd/&& run-parts --report  /etc/cron.daily) 
47 6 * * 7 root test -x /usr/sbin/anacron || (cd/&& run-parts --report /etc/cron.weekly) 
52 6 1 * * root test -x /usr/sbin/anacron || (cd/&& run-parts --report /etc/cron.monthly) 

因爲它不會跑我試圖安裝anacron的,但沒有任何變化。

它爲什麼運行小時腳本而不是日常腳本?

非常感謝大家!

回答

1

您是否安裝了anacron?

# dpkg --get-selections | grep anacron 

如果是,它不會運行每日,每週和每月腳本。

+0

好吧,我想兩者兼得。首先沒有anacron,後來我安裝了它。 但沒有任何改變。 – user2032654

3

它可能是,你的日常腳本之一是行爲不端。嘗試手動運行它們。我刪除了logwatch包和cron.daily作業,並再次運行。

這是我的/ etc/crontab中

# /etc/crontab: system-wide crontab 

SHELL=/bin/sh 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 

# m h dom mon dow user command 
16 * * * * root cd/&& run-parts --report /etc/cron.hourly 
12 2 * * * root test -x /usr/sbin/anacron || (cd/&& run-parts --report /etc/cron.daily) 
41 1 * * 7 root test -x /usr/sbin/anacron || (cd/&& run-parts --report /etc/cron.weekly) 
9 3 30 * * root test -x /usr/sbin/anacron || (cd/&& run-parts --report /etc/cron.monthly) 
# 

每日嘗試運行像這樣

run-parts -v --report /etc/cron.daily 

你也可以使用--list或--test更多的輸出。在我的情況我刪除了行爲不端腳本和日常工作再次

工作
1

的運行部分的手冊頁指出:

如果既--lsbsysinit選項也不--regex給出選項,則名稱必須完全上由ASCII的 - 和小寫字母,ASCII數字,ASCII下劃線和ASCII減號連字符。

我認爲它不喜歡你的腳本的名稱。例如它不喜歡擴展名「.sh」,因爲不允許使用點。

1

我有一個wheezy沒有啓動/etc/init.d/anacron

我的解決辦法:

edit /etc/init.d/anacron

需要啓動:$所有

保存並運行:

update-rc.d /etc/init.d/anacron defaults

現在效果很好,當喘息的開始。

1

我和我的一個腳本有同樣的問題在/etc/cron.daily 腳本的名稱是backupBugzilla.sh

重命名腳本backupBugzilla它的工作之後。

1

我有這個問題,這是因爲我的腳本的所有者在/etc/cron.daily不是根。使root所有腳本的所有者/etc/cron.daily

sudo chown root /etc/cron.daily/* 

而且,可以肯定的腳本是可執行的:

sudo chmod +x /etc/cron.daily/*