I am trying to make it so that I can have a script running on my computer that will check to see if a reboot code has been sent, and it will be checking a MySQL database. I have the php script written, but when I run it, it says that to reboot I need to be root.

PHP: shell_exec("/sbin/reboot");

I have tried to edit visudo and added this to bottom of the file:

ALL ALL = NOPASSWD: /sbin/reboot

It still doesn't work. What do I need to do differently?

  • You have to be specific to create titles of questions here on StackExchange. Your title looks selfish and isn't going to help anyone that have the same problem as you, because he's not going to find this question. Note: I'm just trying to explain the comunity rules. ^^ Welcome to ask ubuntu. – Zignd Oct 5 '12 at 1:21

I just figured it out, but I thought I'd put it here in case anyone else needs help. In the PHP script, I needed to run it as sudo:

shell_exec("sudo /sbin/reboot");

Then it doesn't ask for the password and works fine.

  • 2
    5 minutes to figure out the answer? XD – Evandro Silva Oct 4 '12 at 18:20
  • 1
    I had been working on it for the last day or so and thought I wasn't going to be able to get it to work. That's how computer stuff goes...you try 1000 things, and you don't know if you'll get it right on try 17 or 999. – emilyk Oct 4 '12 at 18:31
  • I know what you mean. :) – Evandro Silva Oct 4 '12 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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