@@ -213,10 +213,16 @@ class TimedUnit:
213213 # instead of waiting for ExecStart to exit. Use oneshot as the default instead.
214214 service_type : str = 'oneshot'
215215
216- # How long after system startup or user login to start the unit.
217- # TODO: should have a default here. Maybe 15s?
216+ # How long after systemd service startup should the timer activate? For a user unit, this
217+ # would be from systemd startup for the user. But if linger is enabled, its essentially from
218+ # system startup too.
219+ # NOTE: unless you really want a timer that only starts after system start, prefer
220+ # on_active_sec.
218221 on_startup_sec : str = None
219222
223+ # How long after the timer is started should the service unit activate?
224+ on_active_sec : str = None
225+
220226 # Uses the last activation time of this timer's UNIT (not the timer). If a unit is activated
221227 # by another means (e.g. systemctl start ...), the timer's next run time will be affected.
222228 # The unit's runtime DOES NOT affect the timer's next run time unless it's still running.
@@ -280,7 +286,7 @@ def __post_init__(self):
280286 self .fixed_random_delay = True
281287
282288 if self .start_delay :
283- self .on_startup_sec = self .start_delay
289+ self .on_active_sec = self .start_delay
284290
285291 if self .run_daily :
286292 assert not any ((self .run_every , self .run_delay ))
@@ -304,11 +310,12 @@ def __post_init__(self):
304310 if self .run_delay :
305311 self .on_unit_inactive_sec = self .run_delay
306312
307- if (self .on_unit_active_sec or self .on_unit_inactive_sec ) and not self .on_startup_sec :
313+ if (self .on_unit_active_sec or self .on_unit_inactive_sec ) and not self .on_active_sec :
308314 # A timer that depends on a unit's last run will never fire the first time on it's own.
309- # OnStartupSec is applied retroactively effectively causing the timer to start
310- # immediately upon it's creation.
311- self .on_startup_sec = '1'
315+ # Configure the timer to kick off the unit immediately upon timer activation so the
316+ # service unit runs once and then the other configurations will take care of how
317+ # often it is ran.
318+ self .on_active_sec = '1'
312319
313320 @property
314321 def exec_start (self ):
@@ -340,6 +347,7 @@ def timer(self):
340347 self .option (lines , 'AccuracySec' )
341348 self .option (lines , 'OnCalendar' )
342349 self .option (lines , 'Persistent' )
350+ self .option (lines , 'OnActiveSec' )
343351 self .option (lines , 'OnStartupSec' )
344352 self .option (lines , 'OnUnitActiveSec' )
345353 self .option (lines , 'OnUnitInactiveSec' )
0 commit comments