View Full Version : cron job command
susanth
07-16-2007, 09:35 PM
I'm not sure about what to put in the command space on a cron job. I want to run a script once a day that's located here:
http://www.mywebsite.com/webcards/tools/delay_send.php
When I go over to set up the cron job, this is already in the command space: /home/myusername/. Is that suppose to stay there? Do I just append something to the end of that? Would it be something like: /home/myusername/webcards/tools/delay_send.php? :confused:
Thanks,
Susan
eugene
07-17-2007, 09:32 AM
Ref: http://hostpc.com/community/showpost.php?p=15312&postcount=7
Use the following command:
/usr/bin/curl -s http://www.mywebsite.com/webcards/tools/delay_send.php
susanth
07-17-2007, 01:17 PM
Thank you. Neither Site-Helper, or the flash demo on Cron Jobs was very clear about what "exactly" goes into the command. One more thing, just to be sure I don't blow up the server. I want the script to run at midnight and noon every day, so I put 0,12 for the Hour and 0 for the Minute, and left everything else *. Does that sound right? Thanks again.
eugene
07-18-2007, 08:02 AM
I want the script to run at midnight and noon every day, so I put 0,12 for the Hour and 0 for the Minute, and left everything else *. Does that sound right? Thanks again.
Yes, that sounds correct, however, as many people often schedule jobs to run "on the hour" or especially at midnight, you might consider scheduling your for something like 17 minutes past the hour.
susanth
07-18-2007, 04:38 PM
That's a good idea; I'll change the minute setting. It appears the script ran last night and again today without any problem. Appreciate the help.:)
susanth
08-07-2007, 10:07 PM
Eugene (or anyone), the command you gave me was working fine until I was moved to a different server this weekend. After the move I got the following error when the cron job tried to run:
/bin/sh: /usr/bin/curl: No such file or directory
I ran a phpinfo();, and saw this: with-curl-dir=/usr/local/lib
I thought that was telling me the path to curl, so I tried changing the command to this:
/usr/local/lib/curl -s http://www.mywebsite.com/webcards/tools/delay_send.php
Guess what? Got the same error. Anyone know what the command should be? It's PHP Version 5.2.3, if that helps. Thanks.
eugene
08-08-2007, 12:20 AM
Eugene (or anyone), the command you gave me was working fine until I was moved to a different server this weekend. After the move I got the following error when the cron job tried to run:
/bin/sh: /usr/bin/curl: No such file or directory
I ran a phpinfo();, and saw this: with-curl-dir=/usr/local/lib
I thought that was telling me the path to curl, so I tried changing the command to this:
/usr/local/lib/curl -s http://www.mywebsite.com/webcards/tools/delay_send.php
I just checked. It looks like curl isn't installed on www300. However, wget is installed.
/usr/bin/wget -q -O /dev/null http://www.mywebsite.com/webcards/tools/delay_send.php
susanth
08-08-2007, 05:56 PM
Ok. Thanks a lot. I changed it this morning, and from looking at my logs it looks like it ran today, but does the /dev/null prevent it from writing output anywhere? I used to get an email showing the results using the curl command. Someone needs to create a "Cron Jobs for Dummies" webpage.:p
eugene
08-08-2007, 09:37 PM
Ok. Thanks a lot. I changed it this morning, and from looking at my logs it looks like it ran today, but does the /dev/null prevent it from writing output anywhere? I used to get an email showing the results using the curl command. Someone needs to create a "Cron Jobs for Dummies" webpage.:p
Oh, sorry. I mistakenly assumed you wouldn't want a message! Sorry about that. Yes, piping to /dev/null makes the output disappear.
alange
08-09-2007, 08:36 AM
Why not just execute the php directly:
/usr/local/bin/php /home/username/domains/mywebsite.com/public_html/webcards/tools/delay_send.php
eugene
08-09-2007, 11:24 AM
Why not just execute the php directly:
A lot of scripts are designed to be called by a browser and not executed directly.
susanth
08-09-2007, 03:16 PM
Oh, sorry.
No problem. I'm sorry for pestering you, especially since I'm about to pester you some more.
I would like to get an email showing the output, so I removed the /dev/null, leaving this:
/usr/bin/wget -q -O http://www.mywebsite.com/webcards/tools/delay_send.php
and now I get an email with the following message when it runs:
wget: missing URL
Usage: wget [OPTION]... [url]...
Try `wget --help' for more options.
I've looked at several different sites that offer help with wget, but all I can figure out is that maybe it expects a filename after the -O, or that maybe I should leave the -O off? If I leave the -O off, will I still get an email with the output? Thanks again.
eugene
08-09-2007, 11:01 PM
No problem. I'm sorry for pestering you, especially since I'm about to pester you some more.
I would like to get an email showing the output, so I removed the /dev/null, leaving this:
/usr/bin/wget -q -O http://www.mywebsite.com/webcards/tools/delay_send.php
and now I get an email with the following message when it runs:
wget: missing URL
Usage: wget [OPTION]... [url]...
Try `wget --help' for more options.
I've looked at several different sites that offer help with wget, but all I can figure out is that maybe it expects a filename after the -O, or that maybe I should leave the -O off? If I leave the -O off, will I still get an email with the output? Thanks again.
I don't remember whether cron automatically emails you the output if it isn't null, but I seem to remember that as the default behavior.
That said, either leave out the -O flag or maybe you can put in -O - to have it output to STDOUT. My first move would be to omit the -O.
skidawg
08-10-2007, 11:17 AM
As Eugene has said, leave of the -O part. Then when cron runs, it will send an email to the email account associated with your login (I have recently confirmed this within DA). So if you use the name susanth to log into your DA control panel, when cron completes, it will send any output, via email, to susanth@yourdomain.com.
HTH,
Doug
susanth
08-10-2007, 02:29 PM
My first move would be to omit the -O.
leave of the -O part. Then when cron runs, it will send an email to the email account associated with your login
I decided to try that yesterday evening. I took out the -O, and from looking at my logs it appears that it ran a little after midnight, but I did NOT receive any email. It seems that it only sends me an email if there is an error.
I'm going to try the -O - next, to have it output to STDOUT, but I'm not sure where the output actually goes with that one. Thanks, both of you.
susanth
08-11-2007, 11:06 AM
I changed it to use the -O - (output to STDOUT) yesterday; it ran early this morning and sent me an email with the results. Thanks a lot for your help, Eugene. :)
MoreFiles
08-21-2007, 02:49 PM
so what is the best way to get that cron job to run?
I too moved and can't get my old methods of curl to work.
and we do use the usr/bin rather than (not in addition to) home/userid/
correct?
susanth
08-21-2007, 07:09 PM
I'm using this as the command:
/usr/bin/wget -q -O - http://www.mywebsite.com/webcards/tools/delay_send.php
It works fine, and sends me an email with the output.
MoreFiles
08-22-2007, 04:46 PM
I think both these methods are now working for me
they've also pointed out:
Try this path to curl
/usr/local/bin/curl
/usr/bin/wget
/usr/local/bin/php
/usr/local/bin/curl
What works on www523?
Edi
mathrules
12-26-2008, 12:23 PM
I found that this cronjob command works on server www520:
/usr/bin/curl --silent --compressed http://www.yourdomain.com/subfolder/script.php
I found it here http://drupal.org/cron which at some point was posted by Joe. I don't know what the options (--silent and --compressed) do; perhaps someone can explain.
Anyway, it works for me (schedules a php script as a cronjob).
Powered by vBulletin™ Version 4.0.3 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.