Reputation: 147
I have 3 scripts that do some stuff. I want to run them continously and concurrently.
Let's say for example: First script took 30 minutes to finish. Second - 20 mins. Third - 5 mins.
So I need everyone of them to run immediately after it's finished. The 3 scripts make UPDATE in a same DB, but they need to work separately. They can run together at once, but not couple of times(my english sucks, sorry about that). Let's explain what I mean with example:
firstScript.php is running
secondScript.php is running
thirdScript.php is running
firstScript.php trying to start but it still running. Wait.(till finish)
May be some shell script will do the job, but how?
Upvotes: 2
Views: 205
Reputation: 610
Make a bash script that takes one argument, and have it do something like this:
if [ -f /tmp/$1 ]
then
echo "Script already running"
else
touch /tmp/$1
php $1
rm /tmp/$1
fi
Set up a cron to run this script and pass it the name of the php script you want to run.
Upvotes: 3
Reputation: 5668
You could execute a shell command just before the php script dies. Example :
while($i < 1000)
{
$i++;
}
shell_exec("bin/php.exe some_script.php");
If you are working on a shared hosting account this might not work do to security issues. note the "bin/php.exe" need to be edited for your server, point to where ever your php is installed.
Upvotes: 0