0

I've got a laptop running Lubuntu 13.04 and guest account enabled. People forget to shut it down every day so I figured I'd just put a one line script into root's cron to solve that. No dice. It shows up in the syslog every day like it ran, but the computer doesn't turn off. Is it not possible for root to shutdown the machine when another user (not in wheel) is logged in?

Shell script:

#!/bin/bash
shutdown -h now

Line in root's crontab:

34 18 * * * /root/shutdownDaily.sh

The script is executable:

-rwxr-xr-x 1 root root 28 Sep 9 17:47 shutdownDaily.sh*

1
  • 2
    Conversely, you could just skip the script, if all you're interested in is shutting down and give the full path to the command. 34 18 * * * /sbin/shutdown -h now Sep 13, 2013 at 2:42

1 Answer 1

3

"/sbin" is not in default cron PATH. So you need to add it there.

you can check it with:

*/2 * * * * /bin/echo "$PATH" > /home/myuser/my.log

Result:

[root@localhost vagrant]# cat my.log 
/usr/bin:/bin

Also you can see it in the mail headers sent by cron:

Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
2
  • Although I used inetplumber's solution, I'm going to check this as answered, and not just because I used to live in New Haven. Thanks.
    – Lido
    Sep 13, 2013 at 18:06
  • Thanks, you asked the question i think i answered what you have asked. If everyone will give full solutions, then you will never get better. Sep 13, 2013 at 20:10

Not the answer you're looking for? Browse other questions tagged .