Tausif Khan
Tausif Khan

Reputation: 2278

Giving credentials for a url in cron job

I need to write a cron job which hits a url once every day. Problem is that this url needs authentication. How can I authenticate and hit the url through a cron job?

Thanks

Upvotes: 3

Views: 4152

Answers (2)

aqn
aqn

Reputation: 2602

If you want a helpful answer, you need to answer Adam's question: "Is this 'HTTP authenication' or a regular login?" (though I don't know what he means by "regular login").

Jasonw's answer is extremely unlikely to work.

Adam's answer of wget --http-user=foo --http-passwd=bar http://... is your best bet. In fact, given the "403" return code, I am willing to bet that it is the answer you need.

Upvotes: 1

Jasonw
Jasonw

Reputation: 5064

Then write a script, example from wget manual

# Log in to the server.  This can be done only once.
wget --save-cookies cookies.txt \
--post-data 'user=foo&password=bar' \
http://server.com/auth.php

# Now grab the page or pages we care about.
wget --load-cookies cookies.txt \
-p http://server.com/interesting/article.php

then call this script from user cron or system cron.

Upvotes: 3

Related Questions