Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

executing main periodically in weblogic

 
Andrew Cane
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've created a project with one main function. The main function will perform a routine database cleanup every 5 minutes. Does anyone know how to do this in weblogic 10.3? should I deploy in jar? or exploded folder will be okay? Should I put the main function inside servlet? thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Web apps don't have main functions. But ...

Rather than try to stuff it into weblogic, why not just run it as a scheduled cron job (or whatever the equivalent is on your platform)? Trying to stuff it into a web app is not necessary or advised.
 
Andrew Cane
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the quick reply, good Sir. So, how do we do that? I deply the said application as jar and create the cron job in LINUX (my server is using LINUX)?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your server is Linux, then a cron job is the way to go. It can start up the Java app periodically so that it can perform its cleanup and then exit.
 
Andrew Cane
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay, lets say I've modified the main method to use ScheduledExecutorService and Runnable methods so the main method will do the cleanup periodically, that would mean I don't need to create the cronjob? thanks
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Theoretically you wouldn't. But the job may crash, and would need to be restarted by hand. Or the machine is rebooted. Or you want to pause it. All these scenarios are handled easily if the job gets executed via cron (instead of having it run all the time and doing the scheduling internally). So I would still advise to use a cron job for starting it.
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also if you make the script a database script then you don't even need to start a JVM at all. Just execute the SQL script from cron. There is really no need to use a JVM let alone weblogic for this.
 
Andrew Cane
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay, thanks guys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic