将php文件放在Linux的后台 [英] Put php file in the background on Linux
问题描述
我有一个PHP文件,用于检查MySQL数据库中的字段是否为空. 如果该字段为空,则PHP为更新. 我想在Linux上的背景中为该文件上色. 如果用户创建记录,则后台的PHP文件将被更新. 我的PHP代码:
I have a PHP file that checks if a field in MySQL database is empty. If the field is empty, PHP is an update. I want to color this file in the background on Linux. If a user creates a record, the PHP file in the background will be updated. My PHP code:
<?php
$mysqli = mysqli_connect("localhost","name","pass","database");
$query = 'UPDATE users SET permissions = "content" WHERE permissions = ""';
$n = $mysqli->query($query);
$query = "SELECT * from users";
$result = $mysqli->query($query);
$row = $result->fetch_array(MYSQLI_ASSOC);
$subdominio = $row["name"];
$created_at = $row["created_at"];
?>
我该怎么做? 我可以在Linux的后台使用文件PHP遇到问题吗?性能,速度变慢等等?
How can I do this? I can have problem with it file PHP in the background on Linux? Performance, slow down and etc?
非常感谢!
推荐答案
- 创建PHP文件并将您的代码放在此处. (例如 myfile.php )
- 安装"
screen
":
- Create PHP file and put your code there. (For example myfile.php)
- Install '
screen
' :
Ubuntu& Debian:apt-get -y install screen
Ubuntu & Debian: apt-get -y install screen
CentOS和Fedora:yum -y install screen
CentOS & Fedora: yum -y install screen
****遵循步骤3& 4一直执行myfile.php.并按照步骤5& 6使用crontab每1分钟或每X次执行myfile.php. ****
**** Follow steps 3 & 4 to execute myfile.php all the time. And follow steps 5 & 6 to execute myfile.php every 1 minute or every X time using crontab. ****
- 输入'
screen
'. -
键入'
php myfile.php
'. 并按Ctrl + A + D
最小化/隐藏它. 然后输入'screen -r
'.
- Type '
screen
' . Type '
php myfile.php
' . And minimize/hide it by pressingCtrl + A + D
. And get back to it by typing 'screen -r
' .
键入'crontab -e
'.
这篇关于将php文件放在Linux的后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!