Forum Moderators: coopster

Message Too Old, No Replies

Cron Job - PHP Page

Run a script to call 5 web pages

         

DuckGirl2

10:00 pm on Jun 1, 2010 (gmt 0)

10+ Year Member



I need a script that can be called by a cron job to load 5 successive web pages to force some auto posting that occurs only on a page load. I can't figure out how to do it for 5, I can do it for 1 though. Any help you can give me would be greatly appreciated.

Thank you! Tisha

Matthew1980

10:13 pm on Jun 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there DuckGirl2,

Welcome to the forum ;)

Post the code you have for the one you have working, and perhaps we can see if it can be looped through.

If the code is HUGE it might deter answers so if its relatively small that would be better - I suspect as it will only be a few lines though..

Cheers,
MRb

optik

10:27 pm on Jun 1, 2010 (gmt 0)

10+ Year Member



You could send the page to itself with a hidden field that increments and you check each time.

penders

10:30 pm on Jun 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



5 pages; 5 cron jobs? Or is the 2nd page dependent on output from the 1st...?

DuckGirl2

10:37 pm on Jun 1, 2010 (gmt 0)

10+ Year Member



Thanks all, what I have is 5 Wordpress sites that have posts being generated by email. (via Postie) the Twitter feed (via Post 2 Twitter) isn't being triggered unless someone loads the page. So what I'd like to do is to use Cron to run 1 job that successively hits each page to allow them to load. Doesn't matter if it's successful or not, don't need to do anything with it just ping and load. These Wordpress sites are a conduit to allow the twitter post, so they aren't generating traffic. If it's possible to string them together somehow that would be fine too.

The Cron job that does work is: /web/cgi-bin/php5 "$HOME/html/tweet-agateridge/wp-admin/admin.php"

Does that help clarify?

Tisha

optik

10:18 am on Jun 2, 2010 (gmt 0)

10+ Year Member



I see, I would just do 5 separate cron jobs personally.

Alcoholico

2:12 pm on Jun 2, 2010 (gmt 0)

10+ Year Member



Quick and dirty way to do it:
<?php
$a = file_get_contents('http://example.com/page_1.php');
$b = file_get_contents('http://example.com/page_2.php');
$c = file_get_contents('http://example.com/page_3.php');
$d = file_get_contents('http://example.com/page_4.php');
$e = file_get_contents('http://example.com/page_5.php');
?>

Save it as cron.php and the cron itself could be:

/web/cgi-bin/php5 "$HOME/html/tweet-agateridge/wp-admin/cron.php" 


Perhaps you'd be better off creating a .sh script and use wget though I'm not very good at shell scripting and honestly prefer not to give any advices or suggestions that could potentially break your system.

DuckGirl2

3:43 pm on Jun 2, 2010 (gmt 0)

10+ Year Member



Thank you Alcoholico! I think that will do the trick. :)