how to shut down pc at specified time in ubuntu 9.04

Asked by Rajinder Sandhu

Dear sir,
How to shutdown PC at specified time as the scheduler is asking for root permissions or
 when the crontab is run
crontab 0 * * * * /sbin/shutdown -h now

 the output is as follows:
shutdown: Need to be root
Press ENTER to continue and close this window.
 and after pressing enter we are back to same window

can anything be done to set it right....
Thanks
Rajinder

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu cron Edit question
Assignee:
No assignee Edit question
Solved by:
Steven Danna
Solved:
Last query:
Last reply:
Revision history for this message
Steven Danna (ssd7) said :
#1

Are you putting this line in your personal crontab? If you run:

sudo crontab -e

You will then put that in root's crontab which will mean it will run as root.

Revision history for this message
Torsten Franz (torsten.franz) said :
#2

Maybe:

0 * * * * root /sbin/shutdown -h now
or
0 * * * * sudo /sbin/shutdown -h now

?

Revision history for this message
Best Steven Danna (ssd7) said :
#3

The first example that Torsten Franz gave should work if you use /etc/crontab and the second example will work in your personal crontab if you have set your sudoers file up to not require a password.

For more information on Cron please see:

https://help.ubuntu.com/community/CronHowto

While there are many ways to accomplish your task, I would personally recommend against using /etc/crontab for this, since it can be overwritten by updates.

Revision history for this message
peter (peter-neuweiler) said :
#4

Use shutdown time (for example shutdown 12:15)
Peter

Revision history for this message
Sam_ (and-sam) said :
#5

If not using remote, there is a GUI
GNOME = gshutdown
KDE = kshutdown

Revision history for this message
Rajinder Sandhu (sandy744) said :
#6

Thanks Steven Danna, that solved my question.