I have a working java program, which takes set of files in a folder that user inputs and process them.
Now users don’t require their intervention. They want the program to run every 30 min and process the files from a pre-determined path.
When I googled it I got to know I should use schedulers. So should we go for OS specific scheduler or Java scheduler?
And also how to use the one that is recommended?
Also on system restart the process should start automatically.
Thanks in advance.
Harsha
If the system is more or less always up, use a Java scheduler (google how to use Executor/TimerTask). If you need the process to start automatically on system restart, you need to go the OS specific route.
For windows, schedule a service to run your java program every 30 mins (see http://windows.microsoft.com/en-US/windows7/schedule-a-task for an example). You basically need to run “java -cp {some classpath} {your program}”
For Unix-based systems, set up a cron job that calls your java program every 30 mins.