0

Hi there everyone,

I really need some help.

I have a load of PHP pages that generate XML feeds that need to run hourly for my site to function. Problem is I have run out of cron jobs with my hosting.

I wondered if there was a way of creating 1 PHP script that once the cron job runs it, it runs the other 10-15 pages automatically.

Any help would be greatly received as I am fast running out of ideas.

Thanks in advance.

6
Contributors
10
Replies
11
Views
7 Years
Discussion Span
Last Post by cwarn23
0

A cron job can be set to run any PHP script. You could run a script to run the whole job list unless you need a time gap between tasks. A PHP script cannot be trusted to handle time-delays of any significance.

Another alternative is to setup a task to run from your desktop at certain times. Each task could run a specific php page with handles a specific job.

On both Linux and Windows machines this can be done through an app called "Scheduled Tasks".

If you opt for a desktop option, be sure that your energy-saving settings don't turn off the harddrive or put your computer to sleep.

0

" have a load of PHP pages that generate XML feeds that need to run hourly for my site to function " = 1 cron job

<?php include('job1.php');
include('job2.php');
include('job3.php');
include('job4.php');
include('job5.php');
include('job6.php');
include('job7.php'); 
/* jeopardy music */ 
include('job9999.php'); ?>

Edited by almostbob: n/a

0

I will give this a go. Thanks for the suggestion.

" have a load of PHP pages that generate XML feeds that need to run hourly for my site to function " = 1 cron job

<?php include('job1.php');
include('job2.php');
include('job3.php');
include('job4.php');
include('job5.php');
include('job6.php');
include('job7.php'); 
/* jeopardy music */ 
include('job9999.php'); ?>
0

Whether the multiple includes solution works or not is going to depend on how long the scripts take to run and the server timeout settings. If you're on a shared server, you won't have much control over the timeout settings which may disrupt your scripts after sixty seconds or so. If your scripts are accessing data from other sites, then the time they take to run is likely to vary, depending on routing and server load of the other sites. This means that it may work sometimes and not others.

0

I have done it and it seems to work apart from this error.

Cannot redeclare stripchars()

Any ideas???

" have a load of PHP pages that generate XML feeds that need to run hourly for my site to function " = 1 cron job

<?php include('job1.php');
include('job2.php');
include('job3.php');
include('job4.php');
include('job5.php');
include('job6.php');
include('job7.php'); 
/* jeopardy music */ 
include('job9999.php'); ?>
0

Hi there, the multiple includes seem to work, but I get the error Cannot redeclare stripchars(). Any ideas as to how I can solve this?

Whether the multiple includes solution works or not is going to depend on how long the scripts take to run and the server timeout settings. If you're on a shared server, you won't have much control over the timeout settings which may disrupt your scripts after sixty seconds or so. If your scripts are accessing data from other sites, then the time they take to run is likely to vary, depending on routing and server load of the other sites. This means that it may work sometimes and not others.

0

rather than have one php file include all the others, you could just run the 1st one and have it (at the end) run the second, etc.:
header("Location: job2.php");

Alternative: remove the stripchars() declaration in all but the first file. The problem with this method, is that there could be other functions that will give the same error.

0

You can use function_exists to prevent double definitions:

if (function_exists("function name") {
    function xxx(...) {

    }
}

Edited by chrishea: n/a

0

I would suggest the following:

<?php file_get_contents('http://cronsubdomain.yoursite.com/job1.php');
file_get_contents('http://cronsubdomain.yoursite.com/job2.php');
file_get_contents('http://cronsubdomain.yoursite.com/job3.php');
file_get_contents('http://cronsubdomain.yoursite.com/job4.php');
file_get_contents('http://cronsubdomain.yoursite.com/job5.php');
file_get_contents('http://cronsubdomain.yoursite.com/job6.php');
file_get_contents('http://cronsubdomain.yoursite.com/job7.php');
 ?>

Then you will have no problems with memory limits and function definitions as they are each a separate request.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.