Questions tagged [systemd-unit]

For questions about the design of systemd units, the relationships between units, and writing [Unit] and [Install] sections of systemd unit files. It can also be used for questions about units which do not have their own tag such as systemd targets.

Filter by
Sorted by
Tagged with
31
votes
2answers
14k views

Documentation of =- (equals minus) in systemd unit files

On my Archlinux system, the /usr/lib/systemd/system/mdmonitor.service file contains these lines: [Service] Environment= MDADM_MONITOR_ARGS=--scan EnvironmentFile=-/run/sysconfig/mdadm ExecStartPre=-...
23
votes
4answers
4k views

Why do some unit filenames end with @?

Some applications, like ssh have a unit file that ends with @, like ssh.service and ssh@.service. They contain different contents, but I cannot understand what exactly is the difference in ...
12
votes
3answers
2k views

“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....
10
votes
2answers
4k views

Systemd Unit File - WantedBy and After

I have a question regarding making my own unit (service) file for Systemd. I've read the documentation and had some questions. After searching around, I found this very helpful answer that gives some ...
8
votes
2answers
7k views

Failed to determine supplementary groups: Operation not permitted

I'm trying to set up watchman as a user service. I've followed their documentation as closely as possible. This is what I have: The socket file: [Unit] Description=Watchman socket for user %i [...
8
votes
2answers
2k views

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= ...
4
votes
2answers
2k views

How can I view journalctl logs by unit and identifier with one command?

I have a vpn service unit for which I can view the logs with... journalctl -u vpn I also have a script that interacts with the vpn manually and is logged to journal with... exec > >(systemd-...
4
votes
1answer
2k views

Restart systemd .service with .timer unit

I have the following systemd myscript.service unit that executes an script: [Unit] Description=MyScript Wants=time-sync.target [Service] Type=oneshot RemainAfterExit=true ExecStart=/usr/local/bin/...
3
votes
1answer
251 views

Why are there no device unit files in Debian?

I've been reading up in systemd and doing a little probing regarding device unit-files. According to the man pages: systemd will dynamically create device units for all kernel devices that are ...
3
votes
2answers
5k views

creating OS environment variables using ExecStartPre on Systemd

I have the following unit file: [Unit] Description=Panel for Systemd Services After=network.target [Service] User=pysd Group=pysd PermissionsStartOnly=true WorkingDirectory=/opt/pysd ExecStartPre=/...
3
votes
1answer
1k views

Why does a systemd unit file at `/usr/lib/systemd/system/` still works for Ubuntu?

I understand that systemd stores unit files at different locations for different versions of Linux. On RHEL, it's at /usr/lib/systemd/system/, whereas on Debian-based machines it's at /lib/systemd/...
3
votes
1answer
34 views

Create a new systemd unit/service/timer/sockets with systemctl from the command line?

Given the CLI tool systemctl edit can be used to edit existing systemd units such as services, timers, sockets, devices, mounts, automounts, targets, swap, path, slice, scope or nspawn files and you ...
3
votes
1answer
2k views

How to check status for user level systemd unit

If alice has a user level systemd service unit named foo.service located at /home/alice/.config/systemd/user/foo.service then I can switch user to alice and check the status of the unit using the --...
3
votes
1answer
220 views

Systemd: Start lots of services one after the other without specific depencies

I have a system composed of about 15 services. They have no inter-dependencies (i.e. no service require another to start) and they notify systemd when there start-up is finished (i.e. Type=notify). ...
2
votes
1answer
2k views

Systemd - Invert Conditions in unit file?

I'm attempting to make a systemd service that should only start if a certain file doesn't exist on the file system. If I use ConditionPathExists this will make the service start only when the file in ...
2
votes
1answer
1k views

/run/user/$UID not mounted when daemon starts

When I reboot my Raspberry Pi (Stretch) a daemon fails to start because /run/user/1000 does not exist. This is my unit file: [Unit] Description=SBFspot Upload Daemon [Service] User=pi Type=forking ...
2
votes
0answers
97 views

Stopping broken systemd service on init

I wanted to make a service that can shutdown the server every day at 9:30 pm. But I accidently set it up so the shutdown service runs on boot. So whenever I turn on the server, it shuts itself down ...
1
vote
1answer
2k views

How do I setup user autostart and properly configure systemd user services?

On my arch server, I was setting up users restricted to their home directories. I ran: useradd -m -s /bin/bash username and passwd username I've read this wiki article... I figured I should use ...
1
vote
1answer
869 views

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 --...
1
vote
2answers
1k views

SystemD `Requires` fail when required unit fails for the first time

I have created a SystemD unit to start a service, and that service requires another unit to start beforehand. I've set the depending service with Requires=dependant.service, and that way when ...
1
vote
1answer
975 views

systemd invalid argument - debugging delayed hibernation service file

I'm trying to implement the delayed hibernation unit. I'm on arch/antergos. >>> systemctl enable suspend-to-hibernate.service Failed to enable unit ...to-hibernate.service: Invalid argument ...
1
vote
0answers
10 views

Does systemd “After=” check if services in it are started without failures before starting the service?

example: bar.service: [Unit] After=foo.service if foo.service isn't started correctly, will bar.service start? and what about if foo.service isn't a dependency of anything and will never start?
1
vote
0answers
78 views

How to conditionally execute two different ExecStart commands in one systemd unit file?

I want to conditionally execute either one of (or both of) these commands in a single systemd unit file: ExecStart=/usr/bin/ssh-keygen -t rsa -b 4096 ExecStart=/usr/bin/ssh-keygen -t ed25519 -a 32 ...
1
vote
1answer
236 views

Why does systemd display certain service units that do not have an associated unit-file?

I have been reading up and investigating systemd and systemctl on Debian 8 Jessie. When running $ sudo systemctl list-units --all --type=service a few services appear in the list that have no unit-...
1
vote
0answers
154 views

Initialize postgresql 11 with custom datadir on fedora 31

According to what I learn so far, I should create a new systemd unit file with the provided script. Then I should initialize the datadir. These are the commands I ran: $ sudo /usr/sbin/postgresql-new-...
1
vote
0answers
1k views

Working with systemd unit file override, can it have multiple sections of the same name like [service]

I am interested in trying to override the CPU utilisation of a systemd service. So that I don't lockup the machine on some CPU heavey process that I run periodically. After running systemctl edit ...
1
vote
1answer
205 views

Define systemd service conditional to network ID

I have the following problem: I have my network drive in my home network that I would like to mount via sshfs. Being in my local network I don't have to care that much about encryption and could use ...
1
vote
0answers
309 views

How systemd Type option affects starting other units?

The man page systemd.service(5) explains the Type options for services: Type= Configures the process start-up type for this service unit. One of simple, forking, oneshot, dbus, notify or ...
0
votes
1answer
571 views

How to enable systemd unit to run at startup

I have a service that processes items from a RabbitMQ queue, of which I spool additional instances as the queue grows in size. How can I enable systemd to start a single instance of the unit at ...
0
votes
1answer
222 views

How can I define the output directory a bundled .NET Core SingleFile published app will be deployed to?

I am deploying a .NET Core Worker Service app in linux, as a systemd daemon/service, as recommended. The .NET Core app is published using the SingleFile property, which generates an all-in-one exe ...
0
votes
1answer
72 views

ConditionPathIsEncrypted not supported?

I've created a unit file to mount the /srv partition automatically. It will check first if /dev/mapper/srv exists and then start it. I'd like to take it one step further and only let it be able to ...
0
votes
1answer
2k views

systemd service ends up in “inactive (dead)” after boot

I have added my service to systemd (I am running it on a pi3), it looks like this: [Unit] Description=Oral-B BLE scanner service Wants=network-online.target After=network-online.target ...
0
votes
2answers
33 views

Java systemd service without specifying java -jar

I'm struggling to make a SpringBootApp to run as a service at the moment. The biggest issue is that Devops doesn't allow us to make changes on the Ansible scripts that deploys the artifact and creates ...
0
votes
1answer
795 views

Docker-compose as Systemd unit

I have a systemd unit, that uses the command docker-compose to start and stop a given set of containers. It looks like this: [Unit] Description=... [Service] WorkingDirectory=/opt/tsc-docker ...
0
votes
1answer
28 views

Issue with creating an ubuntu service unit file for a program with a GUI

I am trying to write a unit service file for a program that has a GUI. I have an ubuntu server from DigitalOcean and I connect to it with TightVNC to display:2. The GUI requires a username and ...
0
votes
1answer
636 views

systemd: Unknown key name 'ConditionEnvironment' in section 'Unit'

I'm using systemd version 246: $ systemctl --version systemd 246 (246.2-1-arch) +PAM +AUDIT -SELINUX -IMA -APPARMOR +SMACK -SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +...
0
votes
1answer
287 views

Specify a systemd unit for cronjob

When I run a cronjob, it's nice being able to follow its logs. If I want to see all logs from cron with journalctl, I can select the cron unit (journalctl -u cron). But when I have multiple cronjobs, ...
0
votes
1answer
738 views

systemd multiple unit files for a single service

I am having a postgresql database on SLES 12 SP3 system whose service is managed by systemd through the standard unit file. I wanted to automatically restart the service on failure, so create the ...
0
votes
0answers
13 views

Systemd file for gunicorn. share dynamic OS environment variables before launching workers

I have a flask app running on Ubuntu, using gunicorn with 12 sync workers. I have an environment file .env in which I set some secrets in the wsgi. I get those secrets through an API, but that API has ...
0
votes
0answers
26 views

starting wsgi as a service fails on startup

I am trying to deploy a flask application inside my WSGI container. I have tried to deploy it by symply executing the same commands within [Service] tags in the unit declaration; this means that I ...
0
votes
0answers
15 views

Systemd wait for specific docker container before running unit

I have to wait for a service before starting a program. That's my actual unit: [Unit] Description = Tempgraph Service After = network.target [Service] Type = simple ExecStart = /opt/Go-...
0
votes
1answer
34 views

Multiple Instances of Unit= in Path or Timer Unit?

Can multiple instances of Unit= exist in a systemd.path or systemd.timer unit? Or, must one instead specify multiple instances of the path or timer unit, each with a single instance of Unit=? I ...
0
votes
1answer
61 views

Enable service for specific user Only (UBUNTU)

Currently writing a service unit file in Ubuntu, i want the service to be enabled for one user UserA only. The service will run automatically when UserA login but not for other users. How can I do ...
0
votes
0answers
75 views

Stop systemd from running user unit for user jenkins

I just installed jenkins on my pop-os following the instruction and install several plugins in jenkins when I found that several gnome user unit is started for user jenkins I tried restarting my ...
0
votes
0answers
39 views

systemd unit triggered on network interface

I'm new to systemd and unit files and I'm trying to find a way to have my unit running only when a network interface exist. My unit file starts a web server and I only want it active when wlan1 exist....
0
votes
1answer
39 views

How do I find out which system unit is causing nologin not to be removed?

My machine is not booting and I have tracked it down to GDM not starting because is says there is a nologin file. How can I find out what is causing this to not be deleted? All systemd units have ...
0
votes
0answers
810 views

systemd unit indirect status

I wonder how can I check which unit activates another with status indirect? I run Arch with Gnome and a Debian server. On my Debian machine I can see that output for systemctl list-unit-files --type=...
0
votes
1answer
23 views

What exactly happens with wanted and conflicted units while isolating to target

Following use case: unit A and unit B are wanted by target T. Unit A conflicts B. Unit B is started before unit A. System boots into target T. If I understand the docs correctly, unit A will stop ...
0
votes
1answer
76 views

Inverse Requsite= dependency / stronger Conflicts= in a systemd unit file

I have two systemd units A and B, which should not be running simultaneously. Both provide access to the same resource, but in different ways, and one handles being stopped 'from outside' less ...
0
votes
1answer
57 views

Trying to run a postgres script as another user from a Unit file, but variable is not being passed

I have a docker container, and -e DEV_ENV is defined with the docker run command, and this the unit file I built to run a script... [Unit] Description=Script that creates environement users and ...