Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP脚本中启动redis服务器进程_Php_Shell_Unix_Redis_Shell Exec - Fatal编程技术网

在PHP脚本中启动redis服务器进程

在PHP脚本中启动redis服务器进程,php,shell,unix,redis,shell-exec,Php,Shell,Unix,Redis,Shell Exec,在PHP脚本中,我使用redis cli ping定期检查我的redis服务器是否正在运行 如果返回NULL,我想在同一个脚本中重新启动redis服务器,然后再次ping redis 最好的方法是什么 我最近使用的是shell\u exec(“redis server”),但这会使PHP脚本挂起(因为它在同一个过程中启动屏幕)。有没有一种方法可以在PHP中运行screen redis server,而无需挂断当前脚本 我也尝试过exec(“sh”.\uu DIR\uuu./start\u red

在PHP脚本中,我使用
redis cli ping
定期检查我的redis服务器是否正在运行

如果返回
NULL
,我想在同一个脚本中重新启动redis服务器,然后再次ping redis

最好的方法是什么

我最近使用的是
shell\u exec(“redis server”)
,但这会使PHP脚本挂起(因为它在同一个过程中启动屏幕)。有没有一种方法可以在PHP中运行
screen redis server
,而无需挂断当前脚本


我也尝试过
exec(“sh”.\uu DIR\uuu./start\u redis.sh”)
,它包含
屏幕redis服务器
,但没有任何作用。

很可能它不是作为守护进程运行的,因此它挂起了。退房:

将其设置为守护进程后,shell_exec()调用应立即返回

您还应该确保php脚本以与redis服务器相同的有效用户身份运行