You are here:  » Cron jobs


Cron jobs

Submitted by philstone on Fri, 2006-03-31 09:05 in

Hi

I'me having dificulty getting cron jobs to work, is there anywhere i could find good "How to's" for cron jobs

got this message back:

Your Terminal type is unknown!

Enter a terminal type: [vt100]
TERMINAL TYPE IS SET TO vt100
(B)0[?7h[?1h=Getting http://mysite.com/scripts/import.php@MODIFIED
Looking up www.mysite.com 
Making HTTP connection to www.mysite.com
Sending HTTP request. 
HTTP request sent; waiting for response.


[?1l>

Submitted by support on Fri, 2006-03-31 09:12

Found a couple of reference on the web regarding lynx not getting on very well with cron; which you may be using to invoke import.php.

It is worth pointing out, however, that the automation scripts cannot be invoked via an HTTP call directly (unless you write a wrapper script as per the info in this thread).

Instead; they are designed to be called from the shell prompt, another script exectuted by cron, or by cron directly. For example, you could do either of the following:

called directly from cron:

php /path/to/mysite.com/scripts/import.php @MODIFIED

or from within another script, let's say automate.sh:

#!/bin/sh
php /path/to/mysite.com/scripts/import.php @MODIFIED

...and then automate.sh is scheduled via cron.

Hope this helps!

Submitted by philstone on Fri, 2006-03-31 09:54

thsnks dave

will let you know how the next scedule runs

thanks
P Stone

Submitted by philstone on Sat, 2006-04-01 08:00

Hi Dave

the scheduled cron job tried to run this morning, but this error appeared, do you have any ideas what i may be doing wrong

"Status: 404
Content-type: text/html
X-Powered-By: PHP/5.0.4

No input file specified."

or do i need to add the file name to the end of the command line?

php /path/to/mysite.net/scripts/import.php [@ALL|feed.xml] ??

Sorry for annoying you on this one!

phil

Submitted by searley on Sat, 2006-04-01 08:06

In my case i have 1 cron setup to download, and 1 to update

the download is

/home/shopping/public_html/feeds/download.php

the download script is what was taken from elswhere on the forum

the update cron is

/home/shopping/public_html/scripts/import.php @MODIFIED

those are the paths exactly as shown in my crontab, obviously you wont have download.php unless you create one

that is what cron calls, you also have to ensure the files are executable on the server, or you will get permission denied

Submitted by support on Sat, 2006-04-01 08:21

Hi Phil,

That's showing a 404 error, which is a HTTP status; so that sounds like the error generated by a cron job that is trying to fetch something over HTTP by using wget or lynx; rather than the line that is trying to to run the import.php script.

Do you have anything else setup in your cron table that might have caused that error?

Submitted by support on Sat, 2006-04-01 08:29

Although having just said that; I notice that it is PHP 5 that you are running, so that could be its response on the command line if it cannot find the input file. That would imply that where you have:

php /path/to/mysite.net/scripts/import.php @MODIFIED

...that the path (in bold) is wrong, and the file cannot be found, hense it returns 404.

You can run the commands from the command prompt exactly as you have them setup in cron to test that they work. The trick is to make sure that you specify all paths absolutely and don't rely on any path or other environment variables which may not be set when the cron job executes. For example, just login to your box (Telnet or SSH) and enter the commands you have setup in cron directly into the command line and see if you get the same errors that way....

...although if you are configuring your cron jobs through a web interface like Plesk or cPanel you may not have command line access. Can you tell us a little more about your setup and how you are configuring cron?

Submitted by philstone on Sat, 2006-04-01 11:55

Hi Dave

I only have the one cron job setup, my site uses cpanel.

I sent a query to the support, they just wrote back there and said to use the following command line:

/usr/local/bin/php -f /home/buy247/public_html/scripts/import.php @MODIFIED

does this look right to you?

P Stone

Submitted by support on Sat, 2006-04-01 17:10

That looks fine, Phil.