systemd-unit

send notification from one systemd unit to another with python?

send notification from one systemd unit to another with python? I have a systemd unit ‘my-app’ that runs my main python app but I want it to auto-update when there is a new version on a remote server. The detection is watched by another python systemd unit (let’s call it "watch-app") on the same OS …

Total answers: 1

How to specify dynamic "Environment" variables in a systemd unit file?

How to specify dynamic "Environment" variables in a systemd unit file? This $(ls -d…) does not work in a systemd unit file: [Service] Type=forking Environment="ORACLE_HOME=$(ls -d /usr/lib/oracle/*/client64 | sort -rV | head -n1)" Environment="TNS_ADMIN=$(ls -d /usr/lib/oracle/*/client64/lib/network/admin | sort -rV | head -n1)" I want to avoid hard-coding the Oracle client version (at the moment 19.19), …

Total answers: 1

What exactly does it mean for a systemd service to be "activating"?

What exactly does it mean for a systemd service to be "activating"? According to various clauses in the docs, the "activating" state is the transition between inactive states and an active state. So far so obvious. But how exactly is it defined? What determines whether a service is no longer inactive but activating? What determines …

Total answers: 1

Systemd executable failed to read file from CacheDirectory with Permission Denied

Systemd executable failed to read file from CacheDirectory with Permission Denied I have a Golang binary that runs every 5 mins. It is supposed to create & update a text file which needs to be write restricted. To run this binary I created a systemd service and a systemd timer unit. Systemd service uses a …

Total answers: 1

Why systemctl status shows a time in the future and the amount of time left?

Why systemctl status shows a time in the future and the amount of time left? When we issue "systemctl status", we usually get in the output, a line showing the status and for how long it has been in that status. Like: (I issued that few minutes ago) Active: active (running) since Wed 2023-11-22 01:56:06 …

Total answers: 1

Reorder of launching Systemd services

Reorder of launching Systemd services OS: Debian 11 Bullseye Context: The Zerotier application adds the zerotier-one.service system service and creates a virtual network interface (when it works). The sshd server default listens to all addresses 0.0.0.0 Until then, everything is fine with me Now I am introducing custom config in /etc/ssh/sshd_config.d/my-sshd.conf add ListenAddress 192.168.10.10 that …

Total answers: 2

systemd unit "Before=" with timer

systemd unit "Before=" with timer In my system I have b.service activated by b.timer. I want another service (a.service) that start before b.service. I cant change b.service or b.timer because are not mine. I’ve putte Before=b.service in a.service but the timer start b.service without starting a.service. Asked By: Andrea Romano || Source You can mark …

Total answers: 2

systemd.time – OnCalendar= unwanted running after suspend

systemd.time – OnCalendar= unwanted running after suspend I wanted a "more stupid" version of crontab: Run only on given times, don’t catch up after suspension. I.e. when a service should have been triggered by crontab, but the machine was suspended, it was triggered right after resuming. That’s what I didnt’ want. I solved this by …

Total answers: 3

Make systemd treat unexpected exit as failure

Make systemd treat unexpected exit as failure I’m wrapping a 3rd party executable in a systemd service unit to manage it. I can’t alter the behavior of this program and I don’t really trust its exit codes. I would like to treat any exit that was not caused by systemd as a failure, that includes …

Total answers: 1

Service OnFailure trigerred only after burst limit reached

Service OnFailure trigerred only after burst limit reached I’m using a systemd unit file in order to control a python process running on a server (with systemd v247). This process must be restarted 60 seconds after it exits, either on failure or on success, except if it fails 5 times in 600 seconds. This unit …

Total answers: 1

How to check multiple host name in systemd unit condition

How to check multiple host name in systemd unit condition I’m trying to make a systemd service have a conditional start based on multiple hostname pattern. I’ve tried this without luck: root@linkbox-BI034415:/# systemctl cat mcbapp # /lib/systemd/system/myservice.service [Unit] Description=My Service Wants=another.service After=another.service ConditionHost=HostOne*|HostTwo* Also tried ConditionHost={HostOne*,HostTwo*} [Service] EnvironmentFile=/etc/default/myenv ExecStart=/opt/bin/my-apps Restart=on-failure [Install] WantedBy=multi-user.target Any suggestion ? …

Total answers: 1

systemd – does the `DynamicUser` option work with user units and if so, how?

systemd – does the `DynamicUser` option work with user units and if so, how? For systemd’s system units (the units you operate with systemctl –system (default)), it’s possible to specify DynamicUser=yes to make systemd dynamically allocate a user and group for the service to achieve some sense of sandboxing. However while reading the manual I …

Total answers: 1

What does systemd exit code EXIT_FDS mean?

What does systemd exit code EXIT_FDS mean? I get this message from systemd status after I have stopped my service: Actice: failed (Result: exit-code) <…> Main PID: 4747 (code=exited, status=202/FDS) Status FDS is defined in the docs like this: 202 EXIT_FDS Failed to close unwanted file descriptors, or to adjust passed file descriptors. Starting the …

Total answers: 1

systemd Firewall .service Unit: Type=exec or Type=oneshot?

systemd Firewall .service Unit: Type=exec or Type=oneshot? I’m debugging a firewall .service unit and a few questions arise. One of those questions is the unit’s best service type, either exec or oneshot. Virtually no comparisons of the two appear in my searches, probably because exec is a relatively recent addition to systemd (v.249 IIRC). By …

Total answers: 1

systemd nightmare – ordering my service so it starts at boot and restarts when needed

systemd nightmare – ordering my service so it starts at boot and restarts when needed I can’t wrap my head around systemd unit files. Here’s my scenario, I have a service called: my.service my.service needs to start sometime after boot, whenever everything else is ready, no rush. my.service starts a docker container so I want …

Total answers: 1

Why ssh.service doesn’t start automatically during boot despite being enabled by systemd?

Why ssh.service doesn’t start automatically during boot despite being enabled by systemd? I’m using Debian 11 on a Raspberry Pi 4 (image found here). sshd is properly configured (I only edited /etc/ssh/sshd_config, the rest is completely fresh from system installation) and works correctly when I start it manually. However it doesn’t start automatically by systemd …

Total answers: 3

Why ssh.socket is set to conflict with ssh.service (Ubuntu 18.04.3)?

Why ssh.socket is set to conflict with ssh.service (Ubuntu 18.04.3)? Description of condition I ran into a strange condition with systemd and ssh on Ubuntu 18.04.3 LTS I checked the status of the ssh.socket unit: $ systemctl status ssh.socket ● ssh.socket – OpenBSD Secure Shell server socket Loaded: loaded (/lib/systemd/system/ssh.socket; disabled; vendor preset: enabled) Active: …

Total answers: 2

Best practice for Wants= vs WantedBy= in Systemd Unit Files

Best practice for Wants= vs WantedBy= in Systemd Unit Files As far as I can tell from the documentation of systemd, Wants= and WantedBy= perform the same function, except that the former is put in the dependent unit file and vice-versa. (That, and WantedBy= creates the unit.type.wants directory and populates it with symlinks.) From DigitalOcean: …

Total answers: 2

Use dynamic date in systemd unit

Use dynamic date in systemd unit I try use date output as part of log file name in systemd unit. Here example: [Unit] Description=TCS minetest server unit [Service] Type=simple ExecStart=/home/tcs/minetest/bin/minetestserver –worldname world –logfile /home/tcs/logs/debug_$$(date +%%Y_%%m_%%d).txt ExecReload=/bin/kill -HUP $MAINPID User=tcs [Install] WantedBy=multi-user.target But I get the log file: ls /home/tcs/logs/ ‘debug_$(date’ How I can use current …

Total answers: 2

"before" and "want" for the same systemd service?

"before" and "want" for the same systemd service? In this example of a systemd unit file: # systemd-timesyncd.service … Before=time-sync.target sysinit.target shutdown.target Conflicts=shutdown.target Wants=time-sync.target systemd-timesyncd.service should start before time-sync.target. This defines an ordering dependency. But at the same systemd-timesyncd.service wants time-sync.target. So time-sync.target is it’s requirement dependency What is the use case for this relation …

Total answers: 3