public abstract class PeriodicWork extends SafeTimerTask implements ExtensionPoint
Timer
.)
This extension point is useful if your plugin needs to perform some work in the background periodically (for example, monitoring, batch processing, garbage collection, etc.)
Put Extension
on your class to have it picked up and registered automatically, or
manually insert this to Trigger.timer
.
This class is designed to run a short task. Implementations whose periodic work takes a long time
to run should extend from AsyncPeriodicWork
instead.
AsyncPeriodicWork
SafeTimerTask.ExceptionRunnable
ExtensionPoint.LegacyInstancesAreScopedToHudson
Modifier and Type | Field and Description |
---|---|
protected static long |
DAY |
protected static long |
HOUR |
protected Logger |
logger
Deprecated.
Use your own logger, or send messages to the logger in
AsyncPeriodicWork.execute(hudson.model.TaskListener) . |
protected static long |
MIN |
Constructor and Description |
---|
PeriodicWork() |
Modifier and Type | Method and Description |
---|---|
static ExtensionList<PeriodicWork> |
all()
Returns all the registered
PeriodicWork s. |
long |
getInitialDelay()
Gets the number of milliseconds til the first execution.
|
abstract long |
getRecurrencePeriod()
Gets the number of milliseconds between successive executions.
|
static void |
init() |
doRun, getLogsRoot, of, run
cancel, scheduledExecutionTime
@Deprecated protected final Logger logger
AsyncPeriodicWork.execute(hudson.model.TaskListener)
.protected static final long MIN
protected static final long HOUR
protected static final long DAY
public abstract long getRecurrencePeriod()
Hudson calls this method once to set up a recurring timer, instead of calling this each time after the previous execution completed. So this class cannot be used to implement a non-regular recurring timer.
IOW, the method should always return the same value.
public long getInitialDelay()
By default it chooses the value randomly between 0 and getRecurrencePeriod()
public static ExtensionList<PeriodicWork> all()
PeriodicWork
s.@Initializer(after=JOB_CONFIG_ADAPTED) public static void init()
Copyright © 2004–2021. All rights reserved.