Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3546

Raspberry Pi OS • Re: Root Script can't shut down, but User Terminal can?

$
0
0
The PATH variable is different when running under cron, to when running in the shell.

From a root shell prompt it is

Code:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
from a root cron job it is

Code:

PATH=/usr/bin:/bin
Solutions to this are to add the full PATH to your crontab, add it to your cron script, or use the full pathname of the command "/usr/sbin/shutdown". I prefer the full pathname as that ensures it uses the correct command and not an alternative from, say, /usr/local/bin.
That would do it. I feel like I knew this at one point, but I don't use it enough to have it stick. Thanks!

-
[shameless self promotion]
Cron – A Beginner's Guide
[/shameless self promotion]
Nice! Thank you! Downloaded, read, and filed. Maybe I'll find it again later???

-
Do you have not by chance forgotten to make your script executable ?
It does everything else, and it writes a logfile, so clearly it's running...

Statistics: Posted by AaronD — Thu Aug 14, 2025 6:03 pm



Viewing all articles
Browse latest Browse all 3546

Trending Articles