call a restful service via cron -- JAVA

  I have a java restful web service  that reads some information from a file  store it in a DB.. I like to schedule this job run on a specific interval.. How do I call a restful service from a cron job

Thanks for your help
chand pbAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use cURL in unix

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Yes like gurpsbassi said, you can have your cron job run a script.  That script will in turn contain a call to "curl" to your web service.

You feed the URL to curl, just like you would type it into the browser (but probably using 'localhost' assuming it's running this on the web server) and if you need special options (like using POST over GET) you can do that through options in curl.

Gerwin Jansen, EE MVETopic Advisor Commented:
The lynx text based browser will work also, using the -dump parameter, like this:

lynx -dump http://<host>:<port>/<service> >/dev/null

If you want to check whether the call succeeded, check the return value of the above command using:

if [ $? -ne 0 ];then
   echo "Error calling restful service" >> /path/to/logfile

More on how to setup cron jobs here:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.