- Support
- Questions & Answers
- Timers
Problem
How can I schedule JVM restarts, shutdowns, thread dumps, or other actions with my Java applications?

Solution!
The Java Service Wrapper provides the ability to schedule a number of actions with timers.
What if your application is suffering from a memory leak which requires the JVM to be restarted at least once per week? It needs to be restarted during a time when the system is not used, at times when system administrators are home in bed.
Or if your application needs to be taken down for 10 minutes every night to allow external backups to take place?
Or you may simply want to schedule that some more benign action takes place once every 5 minutes.
Many large applications require the ability to run scheduled tasks or perform actions at specific times or at regular intervals. The problem is that different OS platforms each provide their own way of scheduled actions. When the application needs to be able to run across all of those platorms it is often necessary to implement this functionality for each platform individually.
Solution |
|
The Java Service Wrapper provides a way to schedule tasks such as restarts, shutdowns, thread dumps, custom events, etc. in a cross platform way using the Wrapper's timer functionality. Timers are defined within the Wrapper's configuration file, making it possible to reliably contain all such settings within the application themselves. This makes it easy to deploy the application to multiple servers and know that everything will work consistently. Timers can be scheduled for specific times and days of the week, or at intervals ranging from once per week down to every second. This flexibility makes it easy to plan backups or downtimes at times which least inconvenience your users, and at the same time allows your system administrators to reduce overtime by working regular hours. |
Technical Overview |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The Wrapper allows you to define multiple timers, each using a pair of properties. The first, wrapper.timer.<n>.interval property is used to specify when the timer should be fired. The second, wrapper.timer.<n>.action property is used to specify which action or actions should take place. wrapper.timer.<n>.interval property: The wrapper.timer.<n>.interval property can be used to fire the action at specific times or intervals. Wildcards can be used to specify intervals. The following are a few examples, but please read over the full property documentation to see what all is possible.
wrapper.timer.<n>.action property: The wrapper.timer.<n>.action property is used to specify the action, or what happens, when the timer is fired. In most cases, this is a single action, but multiple actions can be separated by a comma to perform each of them in series. The following are a few examples, but please read over the full property documentation to see what all is possible.
Setting multiple timers: To declare multiple timers, simply add additional properties with unique numbers in place of the "1" above.
We will now cover some interesting uses of timers with your applications.
|
Reference: Configuration Properties |
|
The Java Service Wrapper provides a full set of configuration properties that allows you to make the Wrapper meet your exact needs. Please take a look at the documentation for the individual properties to see all of the possibilities beyond the examples shown above. |















