Solved

Stopping a cronjob script from timing out

Posted on 2008-10-02
3
308 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 500 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 500 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …

738 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