Welcome Guest, Not a member yet? Register   Sign In
Cron Library
#14

[eluser]drewbee[/eluser]
exec forks into the unix background, giving you the ability to launch a process.

Scenario would be as follows:

User loads page>
- cron is fired off
- Available job needs to be launched
- exec(/path/to/script.php) : launches a seperate php process in the background
- cron completes (end of execution)
- forked process runs until complete (end of execution)

Code:
// taken from db query I assume
foreach ($cron_jobs->result AS $job)
{
    exec(escapeshellcmd('/usr/bin/php /cron.php --job=' . $job . ' > /dev/null/ &'));
}
I believe the & at the end of the command tells it to be asynchronous.

It has been a while since I have played with it, but anything can be done. Infact you can use exec to launch your own version of cron tab. Simply use sleep() to make sure it is not spinning the processor to 100% in a loop. But that is a whole other topic.

Also, I believe doing it this way you have to access the get parameters through argv()


Messages In This Thread
Cron Library - by El Forum - 03-09-2009, 11:20 PM
Cron Library - by El Forum - 03-10-2009, 09:27 AM
Cron Library - by El Forum - 03-10-2009, 09:42 AM
Cron Library - by El Forum - 03-10-2009, 07:08 PM
Cron Library - by El Forum - 03-11-2009, 10:10 AM
Cron Library - by El Forum - 03-11-2009, 02:37 PM
Cron Library - by El Forum - 03-12-2009, 06:39 AM
Cron Library - by El Forum - 03-12-2009, 07:42 AM
Cron Library - by El Forum - 03-12-2009, 08:45 AM
Cron Library - by El Forum - 03-12-2009, 08:48 AM
Cron Library - by El Forum - 03-12-2009, 09:03 AM
Cron Library - by El Forum - 03-12-2009, 09:06 AM
Cron Library - by El Forum - 03-12-2009, 09:22 AM
Cron Library - by El Forum - 03-12-2009, 09:36 AM
Cron Library - by El Forum - 03-12-2009, 10:38 AM
Cron Library - by El Forum - 03-13-2009, 12:35 PM
Cron Library - by El Forum - 03-13-2009, 01:07 PM
Cron Library - by El Forum - 03-13-2009, 01:12 PM
Cron Library - by El Forum - 03-13-2009, 02:23 PM
Cron Library - by El Forum - 03-13-2009, 02:45 PM
Cron Library - by El Forum - 03-16-2009, 11:43 AM
Cron Library - by El Forum - 03-16-2009, 01:15 PM
Cron Library - by El Forum - 03-30-2009, 10:43 AM
Cron Library - by El Forum - 01-28-2010, 08:16 AM
Cron Library - by El Forum - 07-31-2012, 01:45 AM
Cron Library - by El Forum - 07-31-2012, 01:59 AM
Cron Library - by El Forum - 08-04-2012, 04:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB