How do i change property values for a systemd service?

  • Man page for systemctl.

    Also see: How do i display the all systemd manager properties?

    set-property option of systemctl.

           set-property NAME ASSIGNMENT...
               Set the specified unit properties at runtime where this is
               supported. This allows changing configuration parameter properties
               such as resource control settings at runtime. Not all properties
               may be changed at runtime, but many resource control settings
               (primarily those in systemd.resource-control(5)) may. The changes
               are applied instantly, and stored on disk for future boots, unless
               --runtime is passed, in which case the settings only apply until
               the next reboot. The syntax of the property assignment follows
               closely the syntax of assignments in unit files.
               Example: systemctl set-property foobar.service CPUShares=777
               Note that this command allows changing multiple properties at the
               same time, which is preferable over setting them individually. Like
               unit file configuration settings, assigning the empty list to list
               parameters will reset the list.

    Note: It does mention no all properties can be changed at runtime.

    To set the CPUShares of the httpd service. Note, This is just random figure to demonstrate the command. The change will be made permanently to the unit file; to make it a temporary change add the --runtime option.

    $ sudo systemctl set-property httpd.service CPUShares=1000

    Verify the setting.

    $ systemctl show httpd.service -p CPUShares

    Note: When working with unit files manually, there are some other steps involved these are not explained as part of this article.

Log in to reply

© Lightnetics 2020