PHP后台进程处于安全模式 [英] PHP background process in safe mode

查看:107
本文介绍了PHP后台进程处于安全模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的php项目中,我应该有一些后台进程,但是在安全模式下,因为我正在共享主机上运行它.

In my php project i should have some background process , but in safe mode , because I'm running it on a shared host.

例如,我的后台进程代码在文件 bg.php 中,并且我希望它被执行,并在其他特定脚本完成时编写.(或者可能会有一些延迟)
我搜了很多.一些建议的库,例如 beanstalkd ,但我认为该库对于我的简单后台流程来说很繁琐,而且对于 PHP 来说也没有好的文档.还有一些人说像 exec()这样的功能在安全模式下是不可能的.

For example my background process code is in the file bg.php and I want it to be executed , write at finish of another specific script.( or maybe with some delay )
I searched a lot. some suggested libraries like beanstalkd but i think this library is heavy for my simple background process and also doesn't have good doc for PHP. some others said functions like exec() which is not possible in safe mode.

  • 1-有没有人对这个问题有简单的解决方案?
  • 2- cpanel中存在的 cron工作也提到了我, 准备在特定时间执行的任务.我可以用这个吗 选择以某种方式解决我的问题?
  • 1- Does anyone have a simple solution for this problem?
  • 2- I were also mentioned by cron jobs existing in cpanel which prepare tasks to be executed on a specific time. can I use this option to solve my problem in some way?

我注意到我想要一个简单而轻巧的解决方案.任何建议深表感谢.

I noted I want a simple and lightweight solution. any suggestions appreciated deeply.

推荐答案

不可能使用HTTP服务器提供的PHP文件,因为所有过程都将在请求结束后消失.

It's not possible use a PHP file served by a HTTP Server because all proceses will die after the request end.

因此cPanel cron是一个不错的选择,您不必总是启用cron条目,只需设置一次该条目并在脚本开始运行后将其禁用即可.

So cPanel cron is a good option, you don't need to have the cron entry always enable, just setup once the entry and disable it after the script start to run.

仅需在cron命令的末尾添加&即可使其在后台运行.

Only you'll need add & at the end of your cron command to make it run as background.

这篇关于PHP后台进程处于安全模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆