Can the system be shut down and restarted through PHP on linux?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.