Difference between revisions of "Rocky 9.x systemd service file configuration options"

From Notes_Wiki
(Created page with "Home > Rocky Linux or CentOS > Rocky Linux 9.x > System Administration > Rocky 9.x systemd or systemctl > Rocky 9.x systemd service file configuration options =OnBootSec= The OnBootSec option in systemd services is used to define a timer relative to the boot time of the system. This timer is triggered when the system has finished booting up and is expressed in seconds. It is primarily useful when configur...")
 
m
 
Line 1: Line 1:
[[Main Page|Home]] > [[Rocky Linux or CentOS]] > [[Rocky Linux 9.x]] > [[Rocky 9.x System Administration|System Administration]] > [[Rocky 9.x systemd or systemctl]] > [[Rocky 9.x systemd service file configuration options]]
[[Main Page|Home]] > [[Rocky Linux or CentOS]] > [[Rocky Linux 9.x]] > [[Rocky 9.x System Administration|System Administration]] > [[Rocky 9.x systemd or systemctl]] > [[Rocky 9.x systemd service file configuration options]]
Note that systemd configuration files can be located at either of following locations:
* /etc/systemd/system
* /lib/systemd/system


=OnBootSec=
=OnBootSec=

Latest revision as of 04:51, 10 April 2024

Home > Rocky Linux or CentOS > Rocky Linux 9.x > System Administration > Rocky 9.x systemd or systemctl > Rocky 9.x systemd service file configuration options

Note that systemd configuration files can be located at either of following locations:

  • /etc/systemd/system
  • /lib/systemd/system


OnBootSec

The OnBootSec option in systemd services is used to define a timer relative to the boot time of the system. This timer is triggered when the system has finished booting up and is expressed in seconds. It is primarily useful when configured in units running in the per-user service manager, as the user service manager is generally started on first login only, not already during boot.

The OnBootSec option is defined in the [Timer] section of a timer unit configuration file, which encodes information about a timer controlled and supervised by systemd, for timer-based activation. For each timer file, a matching unit file must exist, describing the unit to activate when the timer elapses. By default, a service by the same name as the timer (except for the suffix) is activated.

For example, if a timer file is named mytimer.timer, a matching service file named mytimer.service should exist. When the timer elapses, the mytimer.service unit will be activated. The OnBootSec option can be set to a time span in seconds, such as OnBootSec=50, which means the timer will be triggered 50 seconds after the system has finished booting up.

It is important to note that if a timer configured with OnBootSec or OnStartupSec is already in the past when the timer unit is activated, it will immediately elapse and the configured unit is started. This is not the case for timers defined in the other directives, which are monotonic timers, independent of wall-clock time and timezones. If the computer is temporarily suspended, the monotonic clock stops too. If the empty string is assigned to any of these options, the list of timers is reset, and all prior assignments will have no effect.

Example:

OnBootSec=0min


OnUnitActiveSec

The OnUnitActiveSec option in systemd service units is used to define a timer relative to the time since the service referred to by the timer has been actively running. This option specifies the time interval between repetitions of the service unit. When this option is set, the timer will trigger based on the duration since the service was last activated, ensuring that the service runs at specific intervals regardless of other factors like system boot time or other events.

In the context of systemd timers and services, OnUnitActiveSec is crucial for determining when the service should be triggered based on the time elapsed since the service was last actively running. This option allows for precise control over the timing of service executions, ensuring that the service runs at regular intervals defined by the value set for OnUnitActiveSec.

By using OnUnitActiveSec, administrators can schedule services to run at specific time intervals relative to the service's previous activation, providing a flexible and accurate way to manage service execution timing within the systemd environment.

Example:

OnUnitActiveSec=30min


Home > Rocky Linux or CentOS > Rocky Linux 9.x > System Administration > Rocky 9.x systemd or systemctl > Rocky 9.x systemd service file configuration options