I am working on a emailer system that I have to plug in a CMS for a company. I am looking for a way to make the email sender script run in background while the admin may navigate or even close the browsers.
I found the PHP function named ignore_user_abort()
which is required to keep the page running even if it has timed-out.
Now I have three solutions to "start the script" :
I could use an iframe
I could use an Ajax call which I have previously configured to timeout very early. Eg: using the jQuery framework : $.ajaxSetup({ timeout: 1000 });
I could use a cron job but I would like to avoid this solution since they are "virtual" and are unstable on that server.
Is there any other solutions? I dont really like the iframe solution but I already use them with an Ajax uploader script.
I dont want the admin to hit F5 and start a second instance of it.
The company's users have been told to only log in the CMS using Firefox. Thank you
You can run a PHP script in the background using Exec()
.
php docs provide an example on how you can do that:
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With