Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Scheduled tasks (in windows)

Im facing a problem where i want to schedule a certain java application to run every x days, or every x minutes. I really want to have a platform independant solution, but i've given up on hope to find a nice solution.

To achieve the scheduling, i've been through several solutions, one being services and one being to use the windows api. I really dont like to use a service, it doesnt deploy well in my project. I would have to use some scripts to install the service, wich just doesnt seems to be the right solution for me.

I've also been through windows's scheduling services. They seem perfect for the job. But i'm having trouble parsing the command line. I want to be able to modify my task after i installed it. but when i query the command line tool, the output language may vary (locale).

Maybe there is a solution that implements different stategies per operating system?

like image 483
Terraego Avatar asked May 03 '26 09:05

Terraego


2 Answers

Sure, try Quartz. No scripts, no services, just a JAR in your app. All Java - works on any OS.

I don't see why platform-independence is required. My experience is that scheduled jobs rarely move off the server where they're deployed, unless either the need for the job goes away or the server is retired. They just don't move.

If Quartz isn't your cup of tea, I'd recommend finding a server admin who knows Windows better than you do to deploy your cron job and be done with it.

like image 145
duffymo Avatar answered May 04 '26 22:05

duffymo


Although for me "platform independent solution" and "i want to use Windows Scheduling service" are sort of contradictory (and I agree with duffymo that Quartz is probably the best pure Java solution), some Powershell scripting might make manipulating scheduled programs in Windows a bit easier - look here and here and here plus hunderds of other places that discuss Powershell. And modern Windows should all have Powershell on board.

like image 44
fvu Avatar answered May 04 '26 23:05

fvu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!