I'm using a java program which I'm using to start some tools (logstash, filebeat, mongodb). I need to schedule the tools to make them start one after another using the java program. So how can I do such task? What is the best way to schedule the execution of such java program?
If you're using Windows you can use the Windows Task Scheduler.
If you're using a flavor of Linux, then you can use cron
to do the same thing.
https://help.ubuntu.com/community/CronHowto
Just create a batch file that turns around and calls your Java program. You can pass in command-line paramters based on what else you want to start (logstash, filebeat, mongodb, etc.)
You can use ScheduledExecutorService provided by Java
final Runnable beeper = new Runnable() {
public void run() { System.out.println("beep"); }
};
final ScheduledFuture<?> beeperHandle =
scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);
If you use spring then it is a lot simpler by using @Scheduled
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.