Results 1 to 5 of 5
I'm playing with CRON to perform an automated shutdown.
While I'm testing I want CRON to shutdown the PC every 10 min.
Here is the crontab.
# crontab -l
0,10,20,30,40,50 ...
- 02-11-2010 #1Just Joined!
- Join Date
- Jan 2009
- Posts
- 8
CRON shutdown fails
I'm playing with CRON to perform an automated shutdown.
While I'm testing I want CRON to shutdown the PC every 10 min.
Here is the crontab.
# crontab -l
0,10,20,30,40,50 * * * * root /sbin/shutdown -h now
I see the command being run in the CRON log, but the PC doesn't shutdown.
Feb 11 11:06:17 localhost crontab[4808]: (root) LIST (root)
Feb 11 11:07:31 localhost crontab[4813]: (root) BEGIN EDIT (root)
Feb 11 11:07:58 localhost crontab[4813]: (root) END EDIT (root)
Feb 11 11:10:01 localhost CROND[4821]: (root) CMD (root /sbin/shutdown -h now)
How would I debug this to figure why my shutdown command is being ignored?
I'd appreciate any pointers.
Chris
- 02-11-2010 #2
is it set up to deliver mail? a lot of the times if there is output from a cron job it will be mailed (usually to root). So check root's mailbox, it should have some answers.
linux user # 503963
- 02-11-2010 #3Just Joined!
- Join Date
- Jan 2009
- Posts
- 8
Good call!
I had to cat /var/spool/mail/root to read the mail, and here's the problem:
/bin/sh: root: command not found
Looks like it doesn't like the "user" in there.
I stripped out the user so the crontab reads:
0,10,20,30,40,50 * * * * /sbin/shutdown -h now
Now it works like a champ.
Thanks for the help!.
Chris
- 02-11-2010 #4
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=admin@somesite.com
HOME=/
Depending on the distro, I add these lines to my crontab file. Might help. Also a bit of advice, if you want to keep a cronjob from producing an output all together tack this onto the end of your line.
Code:>/dev/null 2>&1
linux user # 503963
- 02-11-2010 #5Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228


Reply With Quote
