• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

executing main periodically in weblogic

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
okay, thanks guys.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic