tags:

views:

29

answers:

2

I am setting up a cron job to run a single PHP script which will include several other PHP scripts. I'm doing it this way so that each script will only run when the previous one is finished executing.

The problem is, I don't necessarily have full control over the content of all the PHP scripts included and therefore, what files are included in those and what variables and classes are used.

I would like to be able to unset or destroy everything set by the previous PHP script before running the next. Is there are way of doing this?

Or perhaps a better solution?

Thanks

+2  A: 

How about having a centralized shell or PHP script that starts each script sequentially?

php -f /path/to/script1
php -f /path/to/script2
php -f /path/to/script3
php -f /path/to/script4
Pekka
Worked perfectly! Thanks!
Brendan Bullen
A: 

http://php.net/manual/en/function.exec.php

Note: 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.

For example:

<?php
exec("ls", $output); // ls is the linux command for listing a directory content for example, so $output would hold the results of it
var_dump($output);
?>
Prix