?
Solved

Stopping a cronjob script from timing out

Posted on 2008-10-02
3
Medium Priority
?
311 Views
Last Modified: 2013-12-12
I'm running a PHP script on my SHARED server (hostgator.com) and I want to run it as a cronjob, but I can't because the script is not working correctly.

The script is meant to load info from eBay through the eBay API.

When I try to test the script in FF, I get a blank webpage after ~2 mins (the script is supposed to write a success message at the end).
In IE, I get the error that the page cannot be displayed (after ~2 mins).

I have taken a look at my mySQL DB, and I noticed that the script WORKS, but stops halfway through (only half the info is loaded).

What could be wrong with it?
Is it timing out, and if so, why doesn't FF say that it's timed out.

To check the phpinfo() settings, you can go to http://www.esentials.net/scriptTests/phpinfo.php

Any ideas?

0
Comment
Question by:sjamal_hsj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Hube02 earned 2000 total points
ID: 22629549
To remove the time limit on php use

set_time_limit(0);

However, the 2 minutes sounds like a server timeout issue rather than a php timeout issue. The Server will impose it's on limits on scripts accessed by a browser. For instance, the server I run on my local machine is set to timeout in 5 minutes, so even if I set the timeout in php to longer the server will stop.

I cannot say why FireFox does not display an error.
0
 

Author Comment

by:sjamal_hsj
ID: 22629688
I was using set_time_limit(600), but I tried set_time_limit(0) and it seems to work fine now

I plan to run this script as a cronjob, so I'd like to know (just in case):

1. Do server timeout issues affect cronjobs? Or only requests from a browser?

2. Is there any way of having a cronjob redirect (sort of like the header function) to continue running the script?

thnx
0
 
LVL 18

Assisted Solution

by:Hube02
Hube02 earned 2000 total points
ID: 22629818
1) Server timeouts should not affect cronjobs, at least not in my experience.

2) I do not believe there is a way to redirect in a cronjob, but, since there are no timeout issues if you use set_time_limit(0) then there is really no reason to

 I used to work at a place that did quite a bit with crons. One in particular I remember was set to run on sunday night at 3 am because it took more than 30 minutes to complete. No I didn't write it, but I inherited it. It would send me an email every week to tell me when it started, when it stopped and usually a list of a couple thousand entries of files that were altered or errors it encountered.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

752 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