Can the system be shut down and restarted through PHP in linux ?! & Nbsp; the server host is CentOS & nbsp;. you have to connect to the server every time you restart or shut down. could you please refer to the PHP page for system implementation? & nbsp; shutdown and restart ?! I can change the permissions involved, but I don't know how to start this operation. Can I use PHP to shut down and restart the system in linux ?!
The server host is CentOS. every time you restart or shut down the server, you have to connect to the server through the client. could you please use the PHP page to shut down or restart the system ?!
I can change the permissions involved in this operation, but I don't know how to start this operation, so I have to know how to implement it! Thank you!
------ Solution --------------------
This is because system () can call a shell shutdown script.
------ Solution --------------------
Shell script
#! /Bin/bash
Sudo halt;
Welcome to my shop http://shop64931694.taobao.com/
Main products: scarves, hats, gloves
------ Solution --------------------
Try exec ("reboot"), but this is related to safe mode.
------ Solution --------------------
This involves permission issues!
------ Solution --------------------
You are willing to give permissions.
------ Solution --------------------
Is that all right?
------ Solution --------------------
You can use shell scripts. linux is very convenient to do this.
------ Solution --------------------
Exec ("reboot ");
------ Solution --------------------
Shell script, which is very convenient for Linux.
------ Solution --------------------
The php execution user must be the root user. in this case, you need to grant the root permission to the web server, but you can also implement it using socket, which is the simplest, simply write a socket server to keep listening, and then use php to send instructions to let him shut down.
------ Solution --------------------
Isn't it hard to restart n multiple times to open an ssh every day?
------ Solution --------------------
Yes.
------ Solution --------------------
As long as you have permissions, you can
------ Solution --------------------
I'm shocked... is it centos?
Which requires frequent restart is windows .....
So, if your centos restarts more than two times a year, your system admin needs to learn more .....
Reference:
Reference:
Isn't it hard to restart n multiple times to open an ssh every day?
Because our end users are not technical personnel and have limited understanding of computers, that is, they will use the level of office! On weekends and holidays, they all want to shut down or restart the server. Therefore, it is very convenient to directly shut down or restart the server in PHP!
------ Solution --------------------
1. if you have to shut down every week, use crontab to create a scheduled task.
2. if it is occasional, let the technicians do it.