View Full Version : [ubuntu] sudo and crontab

Old Jimma
August 15th, 2010, 09:09 AM
Hi Ubuntu Community:

My user crontab executes scripts, which when finished, I want to shutdown my machine and save electricity.

So, I want to shutdown my system using

sudo shutdown -h "now"

in my crontab, also.

However, this command requires the user password to run.

How do I add the password to the sudo shutdown -h "now" command?

Phil Smith
Duluth, GA

August 15th, 2010, 09:22 AM
Just run it as a normal root cron job.

August 15th, 2010, 05:34 PM
You could edit the "sudo" permissions (using visudo(1)) to allow you to run /sbin/shutdown without a password. I think the line would be:

phil = NOPASSWD: /sbin/shutdown