The automatic system turnoff and wakeup script

Turnoff will not shutdown as a cron job

Asked by Brett Jones on 2012-02-15

Hi there.
I am running Ubuntu 10.04 with all the latest updates. Also running a Myth backend and front end on the same machine. I installed the TurnOff scripts and from a command line it works exactly as expected. Run as a Cron job however it does not shut down the computer. The sys.log shows that when the script runs as a cron job it says mythshutdown -c returned 65024. When I immediately run mythshutdown -c -v all as a command it returns value 0 Ok to shutdown. For some strange reason TurnOff thinks it is OK to shut down when run at command line but not so when run as a cron job. Any ideas as the script works exactly as I want apart from this problem.
Thanks in advance.

Question information

Language:
English Edit question
Status:
Solved
For:
TurnOff Edit question
Assignee:
No assignee Edit question
Solved by:
Brett Jones
Solved:
2012-02-17
Last query:
2012-02-17
Last reply:
Brett Jones (brettjones) said : #1

Problem solved.
When running the script from command line I was using 'sudo' which gave the user root priveleges but was not actually the root account. When running the script as a cron job it was running as the root user and that was stopping the script working.

To solve the issue I used 'sudo visudo' to edit /etc/sudoers and added 'brett ALL= NOPASSWD: /home/brett/MyCrons/turnoff.sh' which allowed me to run a starter script that ran the turnoff_system.py script as the local user but with full root privileges from a local user cron job.