View Full Version : Executing PHP Cron jobs
I have a PHP file that I am using to test the DA Cron job feature:
<?php
mail("john@sixblindsheep.com", "Cron test", "This is the test for earthy/cronMail.php");
?>
I have set the Cron for every 20 minutes (just for testing), and the command is:
/home/earthy/cronMail.php
Yet, it does not work. Am I missing anything?
Crons should be called via a "wget" -
So, the command should look like this:
wget http://www.domainname.com/file.php -q -0 /dev/null
the -q -0 (thats a zero) and the /dev/null make it execute without returning a file save on the server...
Try that, should work.
Joe
I use a similar cron job:
wget -q -O /dev/null http://www.domainname.com/cronfile.php
to keep things from getting confusing, I put my cron job scripts in a separate directory. So my cron job is more like:
wget -q -O /dev/null http://www.domainname.com/subdirectory/cronfile.php
A minor note, that's a CAPITOL 'O' (as in Output) not a Zero ;)
The -O /dev/null causes the output of the wget to not be saved. Otherwise you end up with a lot of files in your root directory. This could fill your disk space over time!
The -q causes wget to operate in 'quiet' mode. This keeps you from getting notices in your root mailbox.
Nope... it didn't work.
What is "wget" and what do the switches mean?
Any other suggestions?
John
eugene
12-20-2003, 12:33 PM
GNU Wget is a free software package for retrieving files using HTTP, HTTPS and FTP, the most widely-used Internet protocols. It is a non-interactive commandline tool, so it may easily be called from scripts, cron jobs, terminals without Xsupport, etc.
Wget has many features to make retrieving large files or mirroring entire web or FTP sites easy, including: Can resume aborted downloads, using REST and RANGE
Can use filename wild cards and recursively mirror directories
NLS-based message files for many different languages
Optionally converts absolute links in downloaded documents to relative, so that ownloaded documents may link to each other locally
Runs on most UNIX-like operating systems as well as Microsoft Windows
Supports HTTP and SOCKS proxies
Supports HTTP cookies
Supports persistent HTTP connections
Unattended / background operation
Uses local file timestamps to determine whether documents need to be re-downloaded when mirroring
GNU wget is distributed under the GNU General Public License.
I refer you to the manual (http://www.gnu.org/software/wget/manual/wget-1.8.1/html_mono/wget.html#SEC6) for the options.
http://www.gnu.org/software/wget/manual/wg.../wget.html#SEC6 (http://www.gnu.org/software/wget/manual/wget-1.8.1/html_mono/wget.html#SEC6)
I would use Joe's setup:
wget http://www.domainname.com/file.php -q -O /dev/null
with one minor adjustment, namely, that is a CAPITAL (or GREAT, depending on which English) O, not a zero.
The -q tells wget to suppress its output; -O /dev/null means redirect output to /dev/null (the great blackhole).
-Eugene
P.S. I have tested this to make sure that it works.
eugene
12-20-2003, 01:38 PM
John-
I noticed you indicated the path as /home/earthy/cronMail.php. In order to run a cron job that parses the php, you need to move the file to some place under your public_html directory. As long as you can access the file URL in your web browser, you can use wget.
-Eugene
Powered by vBulletin™ Version 4.0.3 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.