This is sort of a ramification of my previous thread:
Can sudoers sudo in their crontabs? - How?
(edit): But it points out other problems I'm facing using crontabs with sudo commands.
As soon as the system boots, CRON starts executing the jobs that users have in their crontabs at their due time, even if the users have not yet logged in EXCEPT those that include a sudo-command and the user can execute without the need of password identification.
The moment the user loggs in (and even out) CRON is able to execute the jobs that include sudo commands too.
As you can see, one part of the job in the crontab is not being done even if it is in the same script.
16 Jul 23:35:03 ntpdate: adjust time server 188.8.131.52 offset -0.013027 sec
Thu Jul 16 23:35:03 CEST 2009 - ~/cron/ntpdate.sh
17 Jul 00:35:03 ntpdate: adjust time server 184.108.40.206 offset -0.007102 sec
Fri Jul 17 00:35:03 CEST 2009 - ~/cron/ntpdate.sh
<---- System Shutdown ---->
<---- System Reboot ---->
(CRON is not doing all commands in user's crontab s cript:)
Fri Jul 17 11:35:01 CEST 2009 - ~/cron/ntpdate.sh
Fri Jul 17 12:35:01 CEST 2009 - ~/cron/ntpdate.sh
Fri Jul 17 13:35:01 CEST 2009 - ~/cron/ntpdate.sh
<---- user, owner of the crontab, logged in AND OUT at 14:30 ---->
(CRON starts doing ALL commands in user's crontab script, including sudo commands:)
17 Jul 14:35:02 ntpdate: adjust time server 220.127.116.11 offset 0.079122 sec
Fri Jul 17 14:35:02 CEST 2009 - ~/cron/ntpdate.sh
Is this how it should be?
I don't see any reason why.
Is there any way to avoid this?
According to what I have been observing around a user can never be sure if his jobs are going to be done or not until he has done all kinds of unimaginable tests.
A script whose filename includes a dot (file.name) placed in /etc/cron.hourly is not being done.
The same script with an underscore (file_name) in the name is done perfectly.
Is this normal?