LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why my cron job doesn't work (https://www.linuxquestions.org/questions/linux-newbie-8/why-my-cron-job-doesnt-work-686145/)

byng08 11-25-2008 09:09 PM

Why my cron job doesn't work
 
Hi,
Juz funny, this cron job which shut down the machine use to work before but now is not, what went wrong ?

However, when execute the shutdown command it works.
Thank you.

byng08

centos82 11-25-2008 09:15 PM

What user is the cron job setup for? Can you provide the output of crontab -l for that user. Also, why would you want a cronjob to shutdown your server?

byng08 11-25-2008 09:33 PM

Hi,
The output is as below :
35 17 * * 5-7 sync; /sbin/shutdown -h +3 "server shutting down by cron job in 3 minutes time ..."

Is a routine for us to shut down the server during weekend.

rnturn 11-25-2008 10:32 PM

Quote:

35 17 * * 5-7 sync; /sbin/shutdown -h +3 "server shutting down by cron job in 3 minutes time ..."
I think what centos82 is alluding to is that you need to be root or a some other user specifically authorized to execute the shutdown command. Your cron job may be working fine but the shutdown command would be erroring out if the user doesn't have the authority to perform a shutdown. You should have received an email from the cron daemon that would show if any errors occurred.

And I just have to ask: If you're shutting the system down for the weekend (presumably on Friday, i.e. day "5") why would you need to specify Saturday and Sunday. :)


--
Rick

yzhong 11-25-2008 10:46 PM

You can check /var/log/cron to see if that cron job really run, plus run by which user

byng08 11-26-2008 01:00 AM

Hi,
I think I found the error already, the message is not completely type. So soory for sending the wrong output as well.

Thank you.

SqdnGuns 11-26-2008 01:04 AM

Quote:

Originally Posted by byng08 (Post 3354751)
Hi,
I think I found the error already, the message is not completely type. So soory for sending the wrong output as well.

Thank you.

So what was the actual error and how did you fix it?

byng08 11-26-2008 01:17 AM

This message is from the log :
sync; /sbin/shutdown -h +3 "server shutting down by cron job in 3 minut)

Notice that the 3 minut is not completely type.

Thank to all who try to help.


All times are GMT -5. The time now is 11:37 PM.