[Unit] 及 [Timer] 兩個 sections,尤其 [Timer] 包含計時器的設定一定要存在。
[root@kvm8 ~]# man 5 systemd.timer | grep ^OPTIONS -A6
OPTIONS
Timer unit files may include [Unit] and [Install] sections, which are
described in systemd.unit(5).
Timer unit files must include a [Timer] section, which carries
information about the timer it defines. The options specific to the
[Timer] section of timer units are the following:
[root@kvm8 ~]# man 5 systemd.timer | grep OnCalendar=$ -A4
OnCalendar=
Defines realtime (i.e. wallclock) timers with calendar event
expressions. See systemd.time(7) for more information on the syntax
of calendar event expressions. Otherwise, the semantics are similar
to OnActiveSec= and related settings.
[root@kvm8 ~]# man 7 systemd.time | grep ^CALENDAR -A50
CALENDAR EVENTS
Calendar events may be used to refer to one or more points in time in a
single expression. They form a superset of the absolute timestamps
explained above:
Thu,Fri 2012-*-1,5 11:12:13
週 年-月-日 時:分:秒
The above refers to 11:12:13 of the first or fifth day of any month of
the year 2012, but only if that day is a Thursday or Friday.
The weekday specification is optional. If specified, it should consist
of one or more English language weekday names, either in the
abbreviated (Wed) or non-abbreviated (Wednesday) form (case does not
matter), separated by commas. Specifying two weekdays separated by ".."
refers to a range of continuous weekdays. "," and ".." may be
combined freely.
以下以時段"分"為例:
冒號 ".." 時段範圍 3..5 3至5 分
逗號 "," 分隔時段 3,5 3或5 分
星號 "*" 任意時段 * 不指定分,每分都符合
斜線 "/" 每時段重複 0/5 每5分鐘重複一次
In the date and time specifications, any component may be specified as
"*" in which case any value will match. Alternatively, each component
can be specified as a list of values separated by commas. Values may be
suffixed with "/" and a repetition value, which indicates that the
value itself and the value plus all multiples of the repetition value
are matched. Two values separated by ".." may be used to indicate a
range of values; ranges may also be followed with "/" and a repetition
value, in which case the expression matches all times starting with the
start value, and continuing with all multiples of the repetition value
relative to the start value, ending at the end value the latest.
A date specification may use "~" to indicate the last day in a month.
For example, "*-02~03" means "the third last day in February," and "Mon
*-05~07/1" means "the last Monday in May."
日期中的連接號 "~" 代表最後幾天
例如:
"*-02~03" 2月的最後3天
"Mon *-05~07/1" 5月的最後星期一
The seconds component may contain decimal fractions both in the value
and the repetition. All fractions are rounded to 6 decimal places.
Either time or date specification may be omitted, in which case *-*-*
and 00:00:00 is implied, respectively. If the seconds component is not
specified, ":00" is assumed.
不指定時間或日期可以省略,例如
*:0/5 每5分鐘
*:*:0/5 每5秒
Timezone can be specified as the literal string "UTC", or the local
timezone, similar to the supported syntax of timestamps (see above), or
the timezone in the IANA timezone database format (also see above).
The following special expressions may be used as shorthands for longer
normalized forms:
minutely → *-*-* *:*:00
hourly → *-*-* *:00:00
daily → *-*-* 00:00:00
monthly → *-*-01 00:00:00
weekly → Mon *-*-* 00:00:00