Questions tagged [systemd-service]

34 questions
4
votes
2 answers

Prevent a systemd service from starting if another systemd service is running

In systemd (v237 on UbuntuLinux 18.04 bionic), I can create a service file (for A.service), and specify another service Requisite=B.service. Meaning if I try to start A.service and B.service isn't already running, then A.service will not be started.…
Amandasaurus
  • 30,211
  • 62
  • 184
  • 246
3
votes
1 answer

Show a systemd unit file with its overrides merged in

systemctl cat myunit.service prints the contents of the main myunit.service file followed by any override files. Is there a way to print the unit file that systemd will actually use, i.e. the one formed from merging the overrides into the main unit?
Sean
  • 145
  • 5
3
votes
2 answers

How can I run a systemd service after network link has been established?

A while ago I set up a systemd service to run after network comes online per the documentation. This is the unit file: [Unit] Description=Refresh Pacman mirrorlist with…
Evy Bongers
  • 141
  • 1
  • 6
2
votes
2 answers

Systemd timer OnCalendar every minute ending with 5

With OnCalendar systemd timer i can create something like this to run every 5 minutes. OnCalendar=*:0/5 Is it possible to run it at every minute ending at 5 (00:05, 00:15, 00:25...) only? And/or at every minute ending with a 0 (00:00, 00:10,…
CrazyRabbit
  • 119
  • 1
  • 7
2
votes
0 answers

why consul systemd service is failing?

This is my consul.service file. [Unit] Description="HashiCorp Consul - A service mesh…
Chang Zhao
  • 132
  • 1
  • 9
2
votes
1 answer

Systemd Timer Template after boot?

I have a templated timer that calls a templated unit. I use the following to enable and start them: sudo systemctl enable ping@.timer sudo systemctl enable ping@service sudo systemctl start ping@hello.timer This works as expected, and the timer…
Spammy
  • 41
  • 3
1
vote
1 answer

Run Systemd Service After Display Manager

I have a script that changes some Gnome settings which I want to run on startup. The script itself works fine when I run it manually, but I get the following error when I run it as a systemd service: ● startup-user.service - Startup Service …
grandinero
  • 113
  • 4
1
vote
1 answer

Is it possible to use both `After=` and `Before=` options towards the same unit (service) together in systemd service?

The Type=oneshot unit A.service is started hourly by A.timer and it Wants=B.service, but runs Before=B.service. Unit B.service is also Type=oneshot. The requirement here is that their processes should never overlap at run time (oneshot ensures…
1
vote
2 answers

Can't write to /tmp in systemd service with PrivateTmp=true

My apache2 service has PrivateTmp=true. When the service first starts it works fine, but after a few days, writing to /tmp fails with "no such file or directory". To debug I've tried running nsenter -t -m bash and I've confirmed that…
Thayne
  • 206
  • 1
  • 7
1
vote
1 answer

systemd service produces Exec format error

I have created the following systemd service to automatically keep an autossh tunnel open between two servers: #Systemd unit file for autossh [Unit] Description=Autossh Tunnel [Service] Type=forking ExecStart=/usr/bin/autossh -M 20009 -f -N -L…
toom
  • 187
  • 1
  • 4
  • 11
1
vote
0 answers

Generate systemd task on the fly

I'm writing a script to backup each mysql databases separately on from a mysql server, but instead of handling this inside the script I would like to rely on systemd to generate a backup job to get all the benefits from systemd (I/O, nice,…
1
vote
1 answer

Systemd: how to start service after another service started

I have these two services, one is Google start up script service and second one is redis service, I want to start redis service once the startup script service is started and done, I have these following systemd config but my redis services won't…
Jack
  • 121
  • 1
  • 1
  • 4
0
votes
0 answers

How to reduce duplication of configuration directives in systemd unit files?

Suppose I have two service units bar@%i.service and baz@%i.service which are both part of target unit foo@%i.target and share many common configuration directives, as seen below. (In reality, I have more than two service units.) #…
0
votes
0 answers

Systemd NetworkNamespacePath not working

I'm trying to launch an app inside a network namespace from a systemd service. I tried using NetworkNamespacePath= but when I use it all network requests fail. If I launch the app in ExecStart using ip netns exec it works, but it's not very clean…
Fr3ddyDev
  • 101
0
votes
0 answers

Can a bash script detect if it's **not** being run inside a `systemd` service?

I have a bash script. This script can be started as part of a systemd service (or transient systemd task with systemd-run). One can also run it stand alone. How can I see if “the current script” is being run as part of a systemd service? I can see…
Amandasaurus
  • 30,211
  • 62
  • 184
  • 246
1
2 3