Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 536
  • Last Modified:

PHP Script run as cron to call other php scripts

Greetings,
I have a client that requires me to cron 25 php scripts.
instead of calling 25 crons...
can I make one php script to run the other 25, and execute the "Master" PHP from cron?

If so, does anyone have an example?
Thanks.
0
Evan Cutler
Asked:
Evan Cutler
  • 2
  • 2
  • 2
  • +1
2 Solutions
 
arnoldCommented:
Is there data being passed between/among the scripts.
system "script1"
http://stackoverflow.com/questions/732832/php-exec-vs-system-vs-passthru
0
 
Robert SaylorSenior DeveloperCommented:
Yes use system calls.

system('/path/script.php');
0
 
Ray PaseurCommented:
If you can tell us a little more about the scripts and the data we might be able to offer better advice.

You can start asynchronous scripts with a POST-method request.  A single CRON script can use cURL to start multiple other scripts. You might want to learn about ignore_user_abort().

Or you can let each script start the next script, in a cascade.  The cascade would be useful if there are time-line and/or data dependencies.  

Or you can combine the scripts into one larger script.  Perhaps you can use include() to load the scripts one after another.
0
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

 
Evan CutlerVolunteer Chief Information OfficerAuthor Commented:
nothing so difficult in that.
If I use system(), will it wait for the remote script to finish prior to executing the next one?
or can I run multiple at once this way?
0
 
Robert SaylorSenior DeveloperCommented:
You can call multiple with system
0
 
arnoldCommented:
Yes. System will wait till the script exits before control is returned.
0
 
Ray PaseurCommented:
Fortunately all of the PHP functions are documented on the web site.  Example:
http://php.net/manual/en/function.system.php
0
 
Evan CutlerVolunteer Chief Information OfficerAuthor Commented:
Thanks much guys.
Most appreciated.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now