Solved

PHP Script run as cron to call other php scripts

Posted on 2013-06-13
8
512 Views
Last Modified: 2013-06-14
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
Comment
Question by:Evan Cutler
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 76

Accepted Solution

by:
arnold earned 250 total points
ID: 39246521
Is there data being passed between/among the scripts.
system "script1"
http://stackoverflow.com/questions/732832/php-exec-vs-system-vs-passthru
0
 
LVL 6

Assisted Solution

by:Robert Saylor
Robert Saylor earned 250 total points
ID: 39246581
Yes use system calls.

system('/path/script.php');
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39246943
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
 
LVL 9

Author Comment

by:Evan Cutler
ID: 39247325
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 6

Expert Comment

by:Robert Saylor
ID: 39247338
You can call multiple with system
0
 
LVL 76

Expert Comment

by:arnold
ID: 39247420
Yes. System will wait till the script exits before control is returned.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39248079
Fortunately all of the PHP functions are documented on the web site.  Example:
http://php.net/manual/en/function.system.php
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 39249017
Thanks much guys.
Most appreciated.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now