in reply to Simple reboot from perl?

Try: system("shutdown -g0 -r") or die "shutdown failed: $?";

It might give you some more information.

I'm thinking it's the user than is running your webserver. That user will need permission to execute the shutdown command. You can run your webserver as root, probably not a recommended thing to do but it should work. Or opening up permissions to the shutdown command. You'll also want to make sure your webserver is configured to start back up automatically after a reboot.

Replies are listed 'Best First'.
Re^2: Simple reboot from perl?
by moritz (Cardinal) on Nov 04, 2011 at 15:10 UTC

    Unlike other IO commands, system returns 0 on sucess, making the system() or die ... construct rather useless.

    the documentation elaborates quite a bit on the correct way to check for errors. Read it (both of you :-).

    Also I'd never, ever consider running the web server as root, not even for testing. A much saner approach would be to add a sudo rule that allows the www or www-data user to execute just that one command. But the whole idea seems flawed to me. Remote management systems exist.

      ++'d. Yes that was rather silly of me, wasn't it? 'Tis better to go with what's in the moritz documentation link.