Package hudson.scheduler
Class CronTab
java.lang.Object
hudson.scheduler.CronTab
Table for driving scheduled tasks.
- Author:
- Kohsuke Kawaguchi
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionceil
(long t) Computes the nearest future timestamp that matches this cron tab.Seeceil(long)
.Checks if this crontab entry looks reasonable, and if not, return an warning message.floor
(long t) Computes the nearest past timestamp that matched this cron tab.Seefloor(long)
This method modifies the given calendar and returns the same object.Returns the configured time zone, or null if none is configuredstatic String
Checks a prospective crontab specification to see if it could benefit from balanced hashes.toString()
-
Constructor Details
-
CronTab
- Parameters:
format
- the crontab entry to be parsed- Throws:
IllegalArgumentException
- if the crontab entry cannot be parsed
-
CronTab
- Parameters:
format
- the crontab entry to be parsed- Throws:
IllegalArgumentException
- if the crontab entry cannot be parsed
-
CronTab
Deprecated.- Parameters:
format
- the crontab entry to be parsed- Throws:
IllegalArgumentException
- if the crontab entry cannot be parsed
-
CronTab
- Parameters:
format
- the crontab entry to be parsedhash
- Used to spread out token like "@daily". Null to preserve the legacy behaviour of not spreading it out at all.- Throws:
IllegalArgumentException
- if the crontab entry cannot be parsed
-
CronTab
- Parameters:
format
- the crontab entry to be parsedtimezone
- Used to schedule cron in a different timezone. Null to use the default system timezone- Throws:
IllegalArgumentException
- if the crontab entry cannot be parsed- Since:
- 1.615
-
-
Method Details
-
ceil
Computes the nearest future timestamp that matches this cron tab.More precisely, given the time 't', computes another smallest time x such that:
- x ≥ t (inclusive)
- x matches this crontab
Note that if t already matches this cron, it's returned as is.
-
ceil
Seeceil(long)
. This method modifies the given calendar and returns the same object.- Throws:
RareOrImpossibleDateException
- if the date isn't hit in the 2 years after it indicates an impossible (e.g. Jun 31) date, or at least a date too rare to be useful. This addresses JENKINS-41864 and was added in 2.49
-
floor
Computes the nearest past timestamp that matched this cron tab.More precisely, given the time 't', computes another smallest time x such that:
- x <= t (inclusive)
- x matches this crontab
Note that if t already matches this cron, it's returned as is.
-
floor
Seefloor(long)
This method modifies the given calendar and returns the same object.- Throws:
RareOrImpossibleDateException
- if the date isn't hit in the 2 years before it indicates an impossible (e.g. Jun 31) date, or at least a date too rare to be useful. This addresses JENKINS-41864 and was added in 2.49
-
toString
-
checkSanity
Checks if this crontab entry looks reasonable, and if not, return an warning message.The point of this method is to catch syntactically correct but semantically suspicious combinations, like "* 0 * * *"
-
hashify
Checks a prospective crontab specification to see if it could benefit from balanced hashes.- Parameters:
spec
- a (legal) spec- Returns:
- a similar spec that uses a hash, if such a transformation is necessary; null if it is OK as is
- Since:
- 1.510
-
getTimeZone
Returns the configured time zone, or null if none is configured- Returns:
- the configured time zone, or null if none is configured
- Since:
- 2.54
-
CronTab(String, int, Hash)