Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I use centOS 5.7 and I need an account I have on the server to be able to reboot the server.

How do I do this? Should I maybe be worried about security issues with this?

The reason I need it...I want to reboot the server every 6 or 12 hours...haven't yet decided. But I don't want to make a cronjob on root because I want some commands to be run before the reboot and I want the reboot to happen exactly after the commands have been ran...

basically a countdown till the server goes down for a game server.

share|improve this question
    
Do you need the server to reboot or do you just need certain services to terminate for a specific amount of time? –  jscott Jan 6 '12 at 1:50
    
The issue is a lot of data caches for the game and it causes a few problems. Also a nice reboot cleans up everything to run smooth. I've tried stopping the service clearing the cache and then booting the service again...but it's not as good I find. –  Josip Gòdly Zirdum Jan 6 '12 at 2:02
2  
You can simply write a script to run you commands followed by a reboot and run that via cron. There's no need to create a new account. –  John Gardeniers Jan 6 '12 at 2:12

1 Answer 1

up vote 3 down vote accepted

Add the following to /etc/sudoers:

username ALL=/sbin/reboot

Then the user account can call the /sbin/reboot command as: sudo /sbin/reboot and it will be run as root (sudo can be seen as "superuser-do"). And ofcourse replace username with the name of the user account in question. sudo will ask for the users password, though, so if you are going to script this you might want to add the NOPASSWD: argument, like:

username ALL= NOPASSWD: /sbin/reboot

Chose what works best for you!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.