I\'m actually trying to apply this to a script that sends email. The sending email part takes a few seconds which is too long. What I want is for the first script to do its
Other solution :
I use this kind of solution quite a lot ...
I am using jQuery and AJAX to do stuff like this for PHP scripts which take long time.
What you want to use is something called beanstalkd
Details: How can I get a list of all jobs in a beanstalk tube?
It will allow you to queue up jobs (do 1, then 2, then 3. then 4) you can even distribute these tasks across servers (yes for php jobs!).
You can also call the shell and manually call the PHP file. No cron required and no waiting.
http://www.php.net/manual/en/function.exec.php
From the Notes
Section
"If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends."