Reputation: 411
I have a part of my script to automatically shutdown my Mac.
...
print("Shutting down now")
time.sleep(3)
shutdown_now = "echo {} | sudo -S /sbin/shutdown -h now".format(shutdown_info["password"])
subprocess.Popen(shutdown_now, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print("THIS SHOULD NOT DISPLAY")
The script is run in cron. When I receive the cron mail.
...
Shutting down now
THIS SHOULD NOT DISPLAY
?
At EOF
The script executes and finishes without even shutting down my Mac. Am I missing something to be added to my script?
Upvotes: 0
Views: 497
Reputation: 19
I would just use cron to specify the execution of the command, not a script. This just simplifies the troubleshooting.
MM HH DD 00 WW Command
MM: minute
HH: hour
DD: day of the month
OO: month
WW: day of week
Command with full path
So above: as root, execute /usr/sbin/shutdown -h now every day of the week, every month at 11:59 PM.
Upvotes: 1