0

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.

3
  • 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, 2012 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. Jan 6, 2012 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. Jan 6, 2012 at 2:12

1 Answer 1

3

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!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .