• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

command to run a cron job

 
chundottu jacob
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • 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.
 
Peter Rooke
Ranch Hand
Posts: 848
1
Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a API you may wish to look into, Daemon. Hope this helps.
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • 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
 
Stian Almaas
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • 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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18282
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic