Wget Cronjob, Godaddy.

Hello,

I'm trying to automate a wget cronjob for Php 5.4 on Wordpress - using Cpannel on a linux server hosted by Godaddy. Below is the command I'm using, which isn't working.

wget -q -O "[MYHTTPWEBSITE]/wp-cron.php?import_key=[MYIMPORTKEY]&import_id=[MYID]&action=trigger" >/dev/null 2>&1

========== EDIT

Thank you so much for everyone that pitched in, this was the command that eventually worked.

wget -O - "http://mywebsite/wp-cron.php?import\_key=[MYIMPORTKEY]&import_id=[MYID]&action=trigger"

In my case, putting a simple - dash after the -O fixed the problem.
In my case, I simply wanted to call the link to process a script in wp-cron.php.
If someone could clue me/others in as to why the - made the difference I'd appreciate it.

Leave out wget's -q , which stands for "quiet". Also remove the 2>&1 to see which errors/messages are being written to STDERR.

If you want to see all things that are written to STDOUT too, leave out >/dev/null 2>&1 too. This might help to see at which position the errors occure.

1 Like

Thanks for that, I see a little more clearly how the q works now. This is the response I get, suggesting it can't read the URL. I can't post urls here yet, but i've put it in as lynora.co.uk, (with a http above).

wget: missing URL
Usage: wget [OPTION]... ...

Try �wget --help� for more options.

You have to modify your call a little, like this:

wget <options_go_here> --post-data="?import_key=<your call here>...." "your.url.here"

Notice that you may need to save cokkies in a file if you need to operate persistent connections (like in logging into a website, doing something, then logging off). See the --save-cookies=<file> , --load-cookies=<file> and the --keep-session-cookies parameters of wget .

I hope this helps.

bakunin

1 Like

Thank you Bakunin, I see you're splitting the code and removing the ampersands. With a post ID check as well would it look something like this?

wget -O --post-data="?import_key=[mykey]" "import_id=[MYID]" "my.website.url.here"

No, no, you need the ampersands. after the "--post-data" you put everything you have in your URL string, you just keep the URL itself as the last parameter.

Here is an example: When i reply to this thread my browser shows a URL like this:

http://www.unix.com/newreply.php?do=newreply&p=302979733

If i would have to use this in a wget -statement it would look like this:

wget -O -<other options> --post-data="?do=newreply&p=302979733" "http://www.unix.com/newreply.php"

Again, you might need to provide persistent identification information via "--keep-cookies", etc., as i said above.

I hope that clears it up.

bakunin