Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top