1

i am getting a 406 error page with this cron.

EDIT

i've updated the cron to use wget instead, but i am still not getting the output from the page. here is the new crontab:

/usr/bin/wget "https://abc.com/cron/sendBulletinEmails.php" >> /home/abc/public_html/cron/logs/sendBulletinEmails.log

however, this is not even using the log file. i get an email instead. here is the email output:

--09:20:01--  https://abc.com/cron/sendBulletinEmails.php
           => `sendBulletinEmails.php'
Resolving abc.com... 69.91.162.123
Connecting to fin-iq.com|69.91.162.123|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]

    0K                                                         122.58 B/s

09:20:02 (122.58 B/s) - `sendBulletinEmails.php' saved [101]

i've also tried this crontab (to get the right output):

/usr/bin/wget --append-output=/home/abc/public_html/cron/logs/sendBulletinEmails.log "https://abc.com/cron/sendBulletinEmails.php"      

but, this too gives me that same log as the email. the page outputs text, which is what i want logged in my log file. any ideas as to how to make that work?

thanks again!

OLD

here is the crontab (copied from cPanel):

    * * * * * GET https://abc.com/cron/sendBulletinEmails.php >>
/home/abc/public_html/cron/logs/sendBulletinEmails.log

here is the log:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>406 Not Acceptable</title>
</head><body>
<h1>Not Acceptable</h1>
<p>An appropriate representation of the requested resource /cron/sendSurveyEmails.php could not be found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

also, when i run it from my own browser, it works.

any ideas as to why this is happening? thanks =)

Garrett
  • 203
  • 2
  • 5
  • 10

2 Answers2

2

Getting an e-mail from cron is by design. You can disable this by adding >/dev/null 2>&1 to the end of the line. (Read more about cron here: http://adminschoice.com/crontab-quick-reference)

I think the rest of the question could be solved doing a little more reading about wget. You are trying to send the output to a log file using standard output redirection. The contents of that file will only ever be what you would normally see on screen. Wget doesn't display the file itself so output redirection won't work here. The good news is that wget has a built-in switch for managing the output file.

Try this:

/usr/bin/wget -O /home/abc/public_html/cron/logs/sendBulletinEmails.log "https://abc.com/cron/sendBulletinEmails.php" >/dev/null 2>&1
Aaron Copley
  • 12,525
  • 5
  • 47
  • 68
  • amazing. i was using output but i needed the output FILE. thanks for your help. i will use `--output-document=` just so i remember what `-O` really stands for. now, i've looked into that command and i don't see a way to APPEND to my output file. is there a way to do this? thanks! – Garrett Aug 10 '10 at 14:24
  • 1
    None that I see in wget's pages. In thinking about how the tool is designed, it's designed to make a local copy of a remote file. I don't think they imagined a need to append. You could handle that with a script. You would do your wget `-O /path/to/tempfile.log` then, `cat /path/to/tempfile.log >> /path/to/permanentfile.log`. You may need to delete the tempfile when you are done as well so that next time around wget does not create tempfile.log.1, tempfile.log.2, etc.. – Aaron Copley Aug 10 '10 at 14:40
  • perfect. and i thought it would do that too, but it isn't appending, rather it is overwriting the old temp file. thanks for all your help! – Garrett Aug 10 '10 at 14:44
1

The server may be looking for HTTP_USER_AGENT to block automated tools. If available to you, try 'wget'. It supports the -U or --user-agent=AGENT switch on the command line to help your script appear as though it's a valid Firefox / Interner Explorer browser session.

Otherwise, you might need to write a little script to use more robust features of that Perl module and have the cron job run the script instead of calling get directly. I found some examples of this here: http://perlmeme.org/tutorials/lwp.html

Aaron Copley
  • 12,525
  • 5
  • 47
  • 68
  • it looks like it's working. i'm getting a 200 response, but i'd like the output as well. i've updated the question with my new cron =D – Garrett Aug 10 '10 at 13:24