Class CronDaemon

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:
  • Method Details

    • setLogger

      public static void setLogger(Logger logger)
      Sets the logger for the cron daemon errors (not the individual cron jobs).
      Parameters:
      logger - The logger or null to use the default logger
    • addCronJob

      public static void addCronJob(CronJob job, Logger logger)
      Adds a CronJob to 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 a CronJob from 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.