- java.lang.Object
-
- com.aoapps.cron.CronDaemon
-
public final class CronDaemon extends Object
Run cron jobs based on their scheduling requirements. Once per minute it polls each cron job and runs it if it is currently scheduled.If this main task is delayed for more than a minute, schedules will be missed. Some possible causes include the process was stopped (
kill -STOP) or the machine was suspended/hibernated.- Author:
- AO Industries, Inc.
- See Also:
CronJob
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddCronJob(CronJob job, Logger logger)Adds aCronJobto the list of jobs.static voidremoveCronJob(CronJob job)Removes aCronJobfrom the list of jobs.static voidrunImmediately(CronJob job)Runs a CronJob immediately if it is not already running or allows concurrent execution.static voidsetLogger(Logger logger)Sets the logger for the cron daemon errors (not the individual cron jobs).
-
-
-
Method Detail
-
setLogger
public static void setLogger(Logger logger)
Sets the logger for the cron daemon errors (not the individual cron jobs).- Parameters:
logger- The logger ornullto use the default logger
-
addCronJob
public static void addCronJob(CronJob job, Logger logger)
Adds aCronJobto the list of jobs. If the job is already in the list, it will not be added again.
-
removeCronJob
public static void removeCronJob(CronJob job)
Removes aCronJobfrom the list of jobs.
-
runImmediately
public static void runImmediately(CronJob job) throws IllegalStateException
Runs a CronJob immediately if it is not already running or allows concurrent execution.- Throws:
IllegalStateException- If the job has not been added.
-
-