kevinkhan Posted August 2, 2010 Share Posted August 2, 2010 i have a php script which runs for 3 mins collecting email address and im wondering if i can run this script in the background when a user creates an ad on my website www.corkads.ie ?? I dont want the user to see this script running.. I want the user experence to be the exact same as it is now when they create an ad. but when they click post ad this will initiate a script on another hosting account and it will run by itself.. Kind of like a cron job where the script is running but you cant see it... Hope someone can give me a few ideas on how to do this... Quote Link to comment https://forums.phpfreaks.com/topic/209587-php-and-cron-job-question/ Share on other sites More sharing options...
Skewled Posted August 2, 2010 Share Posted August 2, 2010 require_once('cronjob.php'); Couldn't you just include it in the page where they create the ad? They still wouldn't see that script running in the background unless you have output in the script to confirm it's completion. That's what I do. Quote Link to comment https://forums.phpfreaks.com/topic/209587-php-and-cron-job-question/#findComment-1094193 Share on other sites More sharing options...
kevinkhan Posted August 2, 2010 Author Share Posted August 2, 2010 Quote require_once('cronjob.php'); Couldn't you just include it in the page where they create the ad? They still wouldn't see that script running in the background unless you have output in the script to confirm it's completion. That's what I do. but you see the script runs for a few mins collecting email address so i dont want the user to wait.. i want it to be done in the background and i want the user to go to next page of website as quick as possible.. Quote Link to comment https://forums.phpfreaks.com/topic/209587-php-and-cron-job-question/#findComment-1094214 Share on other sites More sharing options...
Skewled Posted August 2, 2010 Share Posted August 2, 2010 Then you'd want to run it using exec.. exec ("/usr/bin/php yourscript.php >/dev/null &"); That will run in the background and at the same time won't keep the user waiting. http://php.net/manual/en/function.exec.php More on that subject can be found there. Hope this helps you out. Quote Link to comment https://forums.phpfreaks.com/topic/209587-php-and-cron-job-question/#findComment-1094227 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.