Setting up cron with Wget

betserd

Verified User
Joined
Oct 29, 2012
Messages
14
Hello All,

I have been trying for many days now and seem to be failing.
I am trying to setup a drupal cronjob with Wget, but somehow I cannot get Wget to find the file.

From external browser I can locate the cronjob which is like;
http://mydomain.com/cron.php?cron_key=xxxxxxxxxxx

When I log in to SSH and type in the following command;
wget "http://mydomain.com/cron.php?cron_key=xxxxxxxxxxx"

It comes back with ERROR 404: Not Found

However wget "google.com" comes back with results. Is seems that wget cannot find a file on its own server. What can this be?
 
Why don't you try to add the cron job in DirectAdmin control panel instead? Then you can try to add it like this:

Code:
wget -O - -q http://mydomain.com/cron.php?cron_key=xxxxxxxxxxx

I have Drupal customer wich use it like that, so it should work.
 
Hi Ditto,

thanks for your answer. the thing is that I have tried to set it up in cron first. It never ran, so I though I'll take one step back and test in SSH if the statement actually works.
Then the problem appeared that Wget cannot hit a local address somehow, but can get to an external address.
Any idea what that might be?
 
It seems to get stranger and stranger. I hope someone can shed a light on this, below are some examples of Wget and the response (77.72.145.170 is the VPS server);

EXTERNAL ADDRESS --------------------------------------------------------------
------------------------------
wget "http://www.directadmin.com/"
--2012-11-19 22:35:47-- http://www.directadmin.com/
Resolving www.directadmin.com... 66.51.122.131
Connecting to www.directadmin.com|66.51.122.131|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11730 (11K) [text/html]
Saving to: âindex.html.9â

100%[===========================================================>] 11,730 36.6K/s in 0.3s

2012-11-19 22:35:48 (36.6 KB/s) - âindex.html.9â


INTERNAL ADDRESS --------------------------------------------------------------
------------------------------
wget "http://www.dirkvanderkooij.nl/cron.php"
--2012-11-19 22:37:52-- http://www.dirkvanderkooij.nl/cron.php
Resolving www.dirkvanderkooij.nl... 2a01:7c8:aaae:14a::1, 77.72.145.170
Connecting to www.dirkvanderkooij.nl|2a01:7c8:aaae:14a::1|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2012-11-19 22:37:52 ERROR 404: Not Found.


BOGUS ADDRESS --------------------------------------------------------------
------------------------------
wget "http://www.thisaddrescannotexistbladiebla.com"
--2012-11-19 22:33:27-- http://www.thisaddrescannotexistbladiebla.com/
Resolving www.thisaddrescannotexistbladiebla.com... 2a01:7c8:aaae:14a::1, 77.72.145.170
Connecting to www.thisaddrescannotexistbladiebla.com|2a01:7c8:aaae:14a::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 44 [text/html]
Saving to: âindex.html.8â

100%[===========================================================>] 44 --.-K/s in 0s

2012-11-19 22:33:27 (2.04 MB/s) - âindex.html.8â



Somehow a bogus address gets routed back to my own vps server and it says it can find it?? A correct local address cannot be found. I am getting more and more confused....
 
Hi Chatwizard,

below the hosts file;
----------------------------------------------------------
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
77.72.145.170 dvdk
77.72.145.170 host1.dirkvanderkooij.nl

resolve.conf
----------------------------------------------
nameserver 80.69.66.67
nameserver 80.69.67.66



SeLLeRoNe,

that might be something, I have run the following script;
$ [ -f /proc/net/if_inet6 ] && echo 'IPv6 ready system!' || echo 'No IPv6 support found! Compile the kernel!!'

And it came out negative. Would this than only affect using wget on the server itself or also the websites hosted on the server for users?
 
eth0 Link encap:Ethernet HWaddr 52:54:00:43:71:8C
inet addr:77.72.145.170 Bcast:77.255.255.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe43:718c/64 Scope:Link
inet6 addr: 2a01:7c8:aaae:14a::1/48 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3927239 errors:0 dropped:0 overruns:0 frame:0
TX packets:3597629 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:741518551 (707.1 MiB) TX bytes:3696304182 (3.4 GiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:98299 errors:0 dropped:0 overruns:0 frame:0
TX packets:98299 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:11358706 (10.8 MiB) TX bytes:11358706 (10.8 MiB)
 
Actually you do have ipv6 enabled:

inet6 addr: fe80::5054:ff:fe43:718c/64 Scope:Link
inet6 addr: 2a01:7c8:aaae:14a::1/48 Scope:Global

But i think apache is not setted up to use that, that's why isnt working.

Your server try to connect via IPv6, but apache dont have any vhost for that.

Regards
 
If that is the case just use the -4 flag with wget to force it to use ipv4.

Something like:

Code:
wget -4 -O - -q http://mydomain.com/cron.php?cron_key=xxxxxxxxxxx
 
Last edited:
thanks for all the answers. I have fixed it now by removing the IP6 from the dns. Since apache cannot handle it I thought it is way safer to just renmove it from the dns. Just had to add it to the spf record again, since mail is sent using the ip6 address.

Strange that apache in Directadmin is not setup to use IP6.

All ok now, thanks a bunch!
 
Back
Top