PHP background process in safe mode

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-31 05:46:07

问题


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

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- 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.


回答1:


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

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.

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



来源:https://stackoverflow.com/questions/12449104/php-background-process-in-safe-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!