Reputation: 149
I have to execute a method in background; the whole script takes around 30 minutes to finish. I make this as background process, my script is still working after the page is refreshed or close browser. But how to keep executing script if user shuts down their system?
Upvotes: 0
Views: 511
Reputation: 568
What do you mean by shut down the system? He turns off the server or logs out of your application? If its the first you could set up a cronjob to run when the user is about to shut down the system. You could code it into your "exit" button (if you have one) and scheduel a cron job to execute your script the next day. If its the latest the just use an asynchronic script in php.
Upvotes: 1
Reputation: 1962
You would have to design the script in such a way that is resumable. This way, when the machine is rebooted a daemon can resume your script and it would continue working.
Of course (and I assume you knew that), you can't make the script continue to run on a machine that is turned off.
Upvotes: 1
Reputation: 191
The script cannot continue if the system is shut down. There is no system that "works" so the php script can continue it's job :)
Upvotes: 0