Cron's runtime of php script

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

Cron's runtime of php script

Post by afbase »

I want to run a cron job of a php script. The script loops/curls ~81,000 webpages so it takes about 5-8 hours to complete (i haven't had enough time to time it!).

I've read on other forums that cron has a limited php runtime of 15 minutes for Ubuntu dapper drake. I was curious as to lengthen the runtime of php scripts.

Code: Select all

25 1 * * * time php /home/clinton/hdd1/coldowl/project/stock/tests/stock_class.php
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Why not break up the number of pages into blocks of say 100 or ten? You can then run the script more often and have it check which blocks aren't in use taking the first one for itself.
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

how on earth do you break up the loop into blocks?

Post by afbase »

I'm not familiar on how to break up loops into sets in mysql.

Code: Select all

$stockdata = new stockdata();

$sqldb=mysql_connect( $stockdata->localhost, $stockdata->mysql_user , $stockdata->mysql_pass  );
	if ( mysql_select_db( intelligent , $sqldb )  ) {
	  print "Select of intelligent complete<br>";
}
	else {
	  die ("Select failed database name intelligent Error number: <b>".mysql_errno().
                                                           " Message: ".mysql_error()."</b>");
}
print "Rows = ".mysql_num_rows($returnval)."<BR>";
$returnval = $stockdata->do_query("SELECT * FROM curldata", $sqldb);

while ($a_record = mysql_fetch_row($returnval)) {
    print "<pre>";echo $a_record[0];print "</PRE>";
	$stockdata->set_ticker($a_record[0]);
	$quiz=$stockdata->get_ticker();
	$stockdata->getdata_storemysql();
}
any suggestions???
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

I think you use MySQL's "OFFSET" and "LIMIT" commands - it should be fairly straightforward. In fact, as long as you sort by last_update_time you can get away with just using "LIMIT".
Post Reply