call a restful service via cron -- JAVA

Hello,
  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?
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.

gurpsbassiCommented:
Use cURL in unix
0

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
dpearsonCommented:
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.

Doug
0
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
fi

More on how to setup cron jobs here:

http://www.experts-exchange.com/articles/17919/How-to-setup-a-crontab-job-in-Linux-Unix.html
0
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
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.