Reputation: 233
I would like to shut down ubuntu in php script.
I tried this exec("shuttown");
and exec("sudo shuttown");
, but it didn't work.
Upvotes: 0
Views: 1167
Reputation: 1744
exec("shutdown -h now");
It's a scary thought though that you would want a PHP script to have root privileges though
Upvotes: 1
Reputation: 5619
You are almost right; you have just misspelled shutdown
, and have not given a time to shutdown.
As Tim Nordenfur said, simply calling shutdown now
will execute that command.
For future reference, if you want to shutdown and restart it is exec("sudo shutdown -r now");
.
Upvotes: 0
Reputation: 14164
The command is shutdown
, and it requires a time given:
exec("shutdown now");
Also note that only root can run shutdown
.
Upvotes: 2