Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the shutdown and restart function of linux by php

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how php implements linux shutdown and restart. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Php to achieve linux shutdown restart function: 1, create a PHP sample file; 2, use PHP to execute linux commands, code statements such as "exec ('/ sbin/reboot');"; 3, add permissions to the restart command.

This article operating environment: linux5.9.8 system, PHP7.1 version, DELL G3 computer

How does php realize the linux shutdown and restart function?

Php realizes linux shutdown and restart function

Sometimes, we can DIY a control panel to implement the shutdown and restart function of linux. As we all know, linux is a file-based operating system, so the shutdown and restart function of the system must meet the following two points

First, know the absolute path of the command

When operating under linux, we can just type in the command. But you can't do this when you execute a linux command with PHP. You need to know the absolute path to the command.

Restart command reboot absolute path / sbin/reboot

Shutdown command shutdown absolute path / sbin/shutdown

Execute the linux command with PHP

There are many functions, which I have introduced in some blog posts before. The exec function is recommended here.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report