|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
com.jarretttaylor.cron.Cron
public class Cron
Manages cron jobs. Format for schedule is as described in the man page from crontab(5) (copied below).
------------------------------------------------------------------------------
The following was taken from the man page for crontab(5):
The time and date fields are:
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 0-31
month 1-12
day of week 0-6 (0 is Sunday)
A field may be an asterisk (*), which always stands for "first-last".
Ranges of numbers are allowed. Ranges are two numbers separated with a
hyphen. The specified range is inclusive. For example, 8-11 for an
"hours" entry specifies execution at hours 8, 9, 10 and 11.
Lists are allowed. A list is a set of numbers (or ranges) separated by
commas. Examples: "1,2,5,9", "0-4,8-12".
Step values can be used in conjunction with ranges. Following a range
with "/<number>" specifies skips of the number's value through the
range. For example, "0-23/2" can be used in the hours field to spec-
ify command execution every other hour (the alternative in the V7 stan-
dard is "0,2,4,6,8,10,12,14,16,18,20,22"). Steps are also permitted
after an asterisk, so if you want to say "every two hours", just use
"*/2".
Note: The day of a command's execution can be specified by two fields
-- day of month, and day of week. If both fields are restricted (ie,
aren't *), the command will be run when either field matches the cur-
rent time. For example, "30 4 1,15 * 5" would cause a command to be
run at 4:30 am on the 1st and 15th of each month, plus every Friday.
Instead of the first five fields, one of eight special strings may appear:
string meaning
------ -------
@reboot Run once, at startup.
@yearly Run once a year, "0 0 1 1 *".
@annually (same as @yearly)
@monthly Run once a month, "0 0 1 * *".
@weekly Run once a week, "0 0 * * 0".
@daily Run once a day, "0 0 * * *".
@midnight (same as @daily)
@hourly Run once an hour, "0 * * * *".
EXAMPLES
run five minutes after midnight, every day
5 0 * * *
run at 2:15pm on the first of every month
15 14 1 * *
run at 10 pm on weekdays
0 22 * * 1-5
run 23 minutes after midn, 2am, 4am ..., everyday
23 0-23/2 * * *
run at 5 after 4 every sunday
5 4 * * 0
AUTHOR (crontab documentation)
Paul Vixie
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary |
|---|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
Cron(java.util.Set<CronJob> inCronJobs,
long inCompensation,
boolean fork)
creates a new Cron scheduler. |
|
| Method Summary | |
|---|---|
void |
disable()
disables cron (pause) |
void |
disableCronJob(java.lang.String id)
disabled the specified cron job |
void |
enable()
enables cron |
void |
enableCronJob(java.lang.String id)
disabled the specified cron job |
boolean |
forceRunCronJob(java.lang.String id)
Runs the specificed job immediately if is not already running (even if it is disabled. |
java.util.Set |
getCronJobs()
returns a set of CronJob objects |
boolean |
isDisabled()
returns true if cron is not allowed to kick off CronRunner processes |
boolean |
isProcessing()
returns true if cron is kicking off CronRunner processes |
void |
reload(java.util.Set<CronJob> inCronJobs,
long inCompensation,
boolean terminateRunningJobs)
Reloads the cron settings. |
void |
reset()
sets the killed flag to false and resets all CronJob objects. |
void |
run()
This loops while "killed" is false (i.e. terminate() has not been called). |
void |
setFirstRun(boolean firstRun)
if firstRun is true, all the enabled startup jobs will be run. |
boolean |
terminate()
calls terminate on all CronRunners and CronJobs. |
void |
terminateCronJob(java.lang.String id)
requests for the specified cron job to terminate. actual terminate depends on the implementing class |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Cron(java.util.Set<CronJob> inCronJobs,
long inCompensation,
boolean fork)
inCronJobs - a Set of CronJob objectsinCompensation - drift compensation time in millisecondsfork - if true, frees the calling thread to return| Method Detail |
|---|
public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic boolean isProcessing()
public boolean isDisabled()
public void enable()
public void disable()
public boolean terminate()
public void reset()
public void reload(java.util.Set<CronJob> inCronJobs,
long inCompensation,
boolean terminateRunningJobs)
inCronJobs - a Set of CronJob objectsinCompensation - drift compensation time in millisecondsterminateRunningJobs - if true, it will attempt to terminate any curretnly running jobspublic void setFirstRun(boolean firstRun)
firstRun - true to request running of the startup jobs
public boolean forceRunCronJob(java.lang.String id)
throws java.lang.RuntimeException
id - the id of the cron job to start
java.lang.RuntimeException - if the specified job name is not found
public void terminateCronJob(java.lang.String id)
throws java.lang.RuntimeException
id - the id of the cron job to terminate
java.lang.RuntimeException - if the specified job name is not found
public void enableCronJob(java.lang.String id)
throws java.lang.RuntimeException
id - the id of the cron job to enable
java.lang.RuntimeException - if the specified job name is not found
public void disableCronJob(java.lang.String id)
throws java.lang.RuntimeException
id - the id of the cron job to disable
java.lang.RuntimeException - if the specified job name is not foundpublic java.util.Set getCronJobs()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||