linux debian crontab job not executed

人走茶凉 提交于 2019-11-28 10:14:23

Oops. Guess I found the "why" or at least, the "how" :

Only renaming the job filename without ".sh" extension solved that issue.

I thought it was a Debian's bug but it isn't, as described in the other answers below.

SOLUTION: rename your script by removing all . or + characters from its name

the /etc/cron.daily scripts are executed by run-parts (see man 8 run-parts).

there you go with a snip from the manpage:

If neither the --lsbsysinit option nor the --regex option is given then the names must consist entirely of upper and lower case letters, digits, underscores, and hyphens.

from /etc/crontab you can see that the daily cron jobs are being run with:

25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

debian doesn't use anacron and there's no --lsbsysinit option specified for run-parts (in that case '.' will be accepted in the cron script filename as per the LSB hierarchical and reserved namespaces)

anyway, to make sure cron will run your script you can always run run-parts and check that your script is listed in the run-parts output:

run-parts --test /etc/cron.daily

or

run-parts --list /etc/cron.daily

I hope my comment helps you understand what the real problem was.

miklosq

All the answers given before are good and acceptable to the question. However, I believe I should add my point as well to make it clear, that Debian Linux OS does not support cron job filenames that include the . or + character. See the relevant section in the Debian Policy Manual.

So this is just to avoid confusion, that it's not a bug. That's how Debian works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!