Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

command to run a cron job

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to set up a cron job via the Cron Job manager available in my CPanel. I have written a servlet that nedds to be executed as a cron job. Can anyone please tell me how to write the command for running this servlet? I know how to set the parameters related to the time,etc. The server company is using a Linux OS.
Thanks
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not believe this is possible, since a servlet's lifecyle is determined by the Servlet Container and cron only has access to the linux/unix environment.

It seems to me this type of job would be better suited for a regular Java program or some other type of executable.

But, if it is possible, I would be greatly interested.
 
Bartender
Posts: 1094
19
Mac OS X IntelliJ IDE Oracle Spring VI Editor Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's a API you may wish to look into, Daemon. Hope this helps.
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to read into curl. It is a command line URL client. With it you can call pages.

curl http://myserver:8080/myapp/servlet/someservlet

You can then cron job it by

*/10 * * * * curl http://myserver:8080/myapp/servlet/someservlet

That will call the servlet every 10 minutes
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've heard a lot of good things about Open Symphony's Quartz: http://www.opensymphony.com/quartz/ . It is an open source job scheduler that can be run in an application server with your servlets. Every job is a Java class so you can do a lot of very cool stuff with it.
If you are going with cron then curl is a very easy solution to your problems, though.
 
Saloon Keeper
Posts: 24825
172
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a simple "touch" or basic data retrieval operation, you can also use cron to schedule executions of the wget (as in "web get") command.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic