i am getting a 406 error page with this cron.


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...
Connecting to fin-iq.com||: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!


here is the crontab (copied from cPanel):

    * * * * * GET https://abc.com/cron/sendBulletinEmails.php >>

here is the log:

<title>406 Not Acceptable</title>
<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>

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

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


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
  • 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

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

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.