Can the system be shut down and restarted by PHP under Linux? How to fix it

Source: Internet
Author: User
Linux can be implemented through the system of PHP shutdown, restart?!
Server host is CentOS, each reboot, shutdown will have to connect through the client, want to ask whether the PHP page can be implemented on the system shutdown, restart operation?!

I can change the permissions involved, but do not know how to get started to achieve such operations, trouble knowing how to achieve the brotherhood under the table! Reply

------Solution--------------------
Because you can call a shell shutdown script from system () try it.
------Solution--------------------
Shell Script
#!/bin/bash
sudo halt;



Welcome to my shop http://shop64931694.taobao.com/
Main: Scarves, hats, gloves
------Solution--------------------
Try exec ("reboot") but this is about safe mode.
------Solution--------------------
This is a matter of permission!
------Solution--------------------
The main you are willing to give permission not impossible
------Solution--------------------
Is this all right?
------Solution--------------------
With Shell scripting, Linux can do this very conveniently.
------Solution--------------------
EXEC ("reboot");
------Solution--------------------
Shell script, Linux to do this is very convenient.
------Solution--------------------
PHP execution user must be root, if this is the case, you need to give Web server root permissions, but you can also use the socket implementation, this is the simplest, simply write a socket server has been listening, and then use PHP to send instructions to let him shut down the machine is good, hehe

------Solution--------------------
It's not going to restart every day. N how hard is it to open an ssh multiple times?
------Solution--------------------
Yes, I can.
------Solution--------------------
As long as you have permission, you can
------Solution--------------------
I was shocked .... Is this still CentOS?

It is windows that needs to be restarted frequently ....

Let's just say, if your CentOS restarts more than 2 times a year, your system admin needs to study hard ....


discuss

Reference:
It's not going to restart every day. N how hard is it to open an ssh multiple times?


Because our end-users are not technicians, we have limited knowledge of computers, which is the level of office! On weekends and holidays they want to shut down or restart the server, so the PHP implementation can be directly shut down, restart the words will be very convenient!

------Solution--------------------
1 if it is to shut down the machine every week, it is better to use crontab to do a timed task.
2 If it is occasional, let the technician 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.