Questions tagged [systemd-service]

The tag has no usage guidance.

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

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 ...
Jack's user avatar
  • 251
10 votes
1 answer
4k views

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 ...
Sean's user avatar
  • 215
5 votes
2 answers
10k views

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 ...
Amandasaurus's user avatar
  • 32.3k
5 votes
2 answers
12k views

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 Reflector. Documentation=https:/...
Evy Bongers's user avatar
4 votes
1 answer
7k views

How to list systemd services by memory usage

I'd like to see which systemd services consume the most amount of memory. Is there a way to list all running (and/or enabled) systemd services by memory usage?
Newskooler's user avatar
3 votes
2 answers
8k views

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 ...
CrazyRabbit's user avatar
2 votes
1 answer
4k views

How can I find the exact cause of systemd service unable to start (service has a bad unit file setting)?

This is really annoying that systemd only responded that my configuration of a service file is wrong, but does not specify where is wrong exactly: /lib/systemd/system/auto_pgha.service: [Unit] ...
George Y's user avatar
  • 560
2 votes
2 answers
470 views

Why doesn't systemd capture output from subprocesses of a user service written in shell script?

Here is my amazing service, written in shell script: $ cat ~/junk/demoapp #! /bin/bash -eu while true do echo "in shell" ( echo "in subshell" ) /usr/bin/echo "in ...
Tom Anderson's user avatar
2 votes
1 answer
514 views

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 ...
Alexander Shukaev's user avatar
2 votes
1 answer
322 views

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 [email protected] sudo systemctl enable ping@service sudo systemctl start ping@hello....
Spammy's user avatar
  • 41
2 votes
1 answer
9k views

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 ...
toom's user avatar
  • 227
2 votes
0 answers
2k views

why consul systemd service is failing?

This is my consul.service file. [Unit] Description="HashiCorp Consul - A service mesh solution" Documentation=https://www.consul.io/ Requires=network-online.target After=network-online....
Chang Zhao's user avatar
1 vote
1 answer
2k views

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 ...
Fr3ddyDev's user avatar
  • 111
1 vote
1 answer
216 views

systemd timer job not working

I want the job to run every day at 2am and 2pm I have this in the .timer file OnCalendar=*-*-* 02:00:00,14:00:00 But when I systemctl start myjob.timer I get this error: Failed to start myjob.timer: ...
guesty's user avatar
  • 65
1 vote
1 answer
4k views

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: ●...
grandinero's user avatar
1 vote
2 answers
3k views

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 ...
Thayne's user avatar
  • 246
1 vote
2 answers
2k views

Restrict a user to only interact with a systemd service via Ansible

I want to have a user that is only able to start/stop/restart/status a service via an Ansible playbook. The playbook looks like this: host: my-server remote_user: my-user tasks: - name: "Start ...
MoaMoaK's user avatar
  • 43
1 vote
1 answer
100 views

Running systemd-run --user inside a systemd service

I have a web app that handles user input, and as part of that, runs some commands with systemd-run --user --scope ... to limit memory and CPU usage. The application runs fine when run normally, but ...
user2141650's user avatar
1 vote
1 answer
101 views

Setting MAINPID from podman container

I'd like to send a systemd notification with readiness and main pid. Unfortunately, it seems like systemd doesn't cope with translating pids from different namespaces. (Just a guess...) Specifically, ...
viraptor's user avatar
  • 1,306
1 vote
0 answers
234 views

Systemd service with DynamicUser cannot write to its CacheDirectory

I'm running OpenSuse Leap 15.4. I have created a unit file for the bazel-remote remote cache server, for the Bazel build system. I wanted to use the DynamicUser feature to make the service more secure,...
dieortin's user avatar
  • 111
1 vote
1 answer
506 views

Why qemu fails to start host only network on loopback when there's no other network on host?

Starting qemu-system-x86_64 with -nic user,ipv6=off,hostfwd=tcp::9022-:22 With only the lo interface (with 127.0.0.1 associated to it) present on the host, the vm will start, but any daemon trying to ...
gcb's user avatar
  • 82
1 vote
2 answers
644 views

Limit systemd service manual restart rate

I have a system where a service (nginx for example) is sometimes restarted excessively by 'systemd restart nginx' (as result from other scripts, eg. to apply a new configuration or rotate logs). Even ...
dronus's user avatar
  • 1,188
1 vote
0 answers
18 views

Marking services for killing in a resource-starvation situation

We use systemd --user to run certain services of our own. In some cases, these "get out of hand" -- spawn way too many processes, which exhausts RAM and causes the machine to "thrash&...
Mikhail T.'s user avatar
  • 2,387
1 vote
0 answers
3k views

Run two scripts one after another with a systemd service

I have two scripts, what I would like to do is: at 1am, the first one runs once the first one stops, and this is a condition, the second one fires So, should i use: [Service] ExecStartPre = script....
CrazyRabbit's user avatar
1 vote
0 answers
134 views

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 ...
Baptiste Mille-Mathias's user avatar
1 vote
1 answer
249 views

Why echo text won't work within systemd service

This bash script worked fine alone: #!/bin/bash OtherIP=172.17.1.2 while [ true ] do echo "cannot connect to $OtherIP" >>pgha.log sleep 2s psql -h $OtherIP -U checker -c '\l' ...
George Y's user avatar
  • 560
0 votes
2 answers
23k views

Can't initialize Redis as a systemd service (supervised systemd) on Ubuntu Server 20.04.2

On Ubuntu Server 20.04, Redis (5.0.7) doesn't start after setting supervised systemd on /etc/redis/redis.conf, but no error is printed when running it manually with /usr/bin/redis-server /etc/redis/...
Paulo Coghi's user avatar
0 votes
1 answer
667 views

How to monitor systemd?

I am looking for a way to monitor systemd services: Basic things such as whether they are running or not is a good start (and anything else on top is a bonus). I tried using node_exporter, but since I ...
Newskooler's user avatar
0 votes
1 answer
5k views

Tail the journalctl log on failure to restart systemd service?

I want to know if there is a brief way to check the last 50 lines about a service that threw an error on restart. $ sudo service nginx restart Job for nginx.service failed because the control process ...
listenlight's user avatar
0 votes
1 answer
246 views

systemd tmpfs shadow directory -- copy to/from ram and back when (u)mount-ing

I'd like to keep some directories (e.g. /var/cache/apt, /var/lib/apt/lists, user browser caches or even Mozilla profiles) in RAM, but still backed by disk. The files should be copied to RAM when ...
usretc's user avatar
  • 101
0 votes
2 answers
1k views

CentOS 7 systemd.exec configuration: alternatives to LogsDirectory & CacheDirectory?

On a CentOS Linux 7.8 system, if I create a systemd service configuration file and include LogsDirectory and/or CacheDirectory in the [Service] section, then do a systemctl daemon-reload, the ...
mhucka's user avatar
  • 699
0 votes
1 answer
121 views

service file disappeared in Google CLoud VM

I have a Google VM micro instance running Ubuntu 20.04. Last week on this VM, I set up a systemd service that runs a python script. I created the service file (say my_fancy_service.service) as /lib/...
Marc's user avatar
  • 151
0 votes
1 answer
327 views

Possible to write a systemd service that starts when another service starts?

This seems like it should be a really simple question but I have had no luck in figuring it out. I have a service 'Alice': [Unit] Description=Alice After=network.target [Service] Type=simple Restart=...
Chris Robison's user avatar
0 votes
1 answer
2k views

Is it possible for a systemd service to update itself?

Hey faultless server folks, I'd like to write a systemd service that can update itself. Specifically, every 5 minutes it should look at Amazon S3 for new versions of its binary and .service files. If ...
emchristiansen's user avatar
0 votes
1 answer
786 views

Verify in ExecStartPre if bash binary exists

I want my service to start only if another service is not active. To do so, as explained in this other question, I am going to do: ExecStartPre=/bin/bash -xc '/usr/bin/systemctl is-active --quiet ...
mosquetero's user avatar
0 votes
1 answer
3k views

How to start a gnome-terminal with command from the systemd service on Ubuntu 20.04?

I wrote e service file called /etc/systemd/system/mytest.service . Then I would like to start a new terminal window with some commands that print on the new terminal console. The file mytest.service ...
ywiyogo's user avatar
  • 121
0 votes
2 answers
179 views

How to ensure that system-userdbd.service is started after root fs became writeable without creating circular dependencies?

I have a fast virtual machine and the systemd service systemd-zserdbd.service fails with Dec 01 17:45:32 server-new systemd[1]: Starting systemd-remount-fs.service... ... Dec 01 17:45:32 server-new (...
user2690527's user avatar
0 votes
0 answers
121 views

Systemd sequencial stop of template unit instances

I have a template unit that that I have to created in order to start/stop some services running an a given port. something like [email protected], [email protected]. [Unit] After=network.target ...
thiebaut fischer's user avatar
0 votes
1 answer
502 views

How can I connect standard output and error of a systemd service to a file with a date in the path?

I would like to run a server process under systemd, and append its standard output and error to a file, where the file path has a date in it, like this: /initech/logs/tps-report-app/sales/2023/09/11/...
Tom Anderson's user avatar
0 votes
1 answer
960 views

Is it possible to set CPUAffinity=0 for a specific process in its systemd service unit file?

Is it possible to set CPUAffinity=0 for a specific process (lets say httpd.service) in its systemd service unit file?
Shubham Saroj's user avatar
0 votes
0 answers
99 views

Is it possible to delay a systemd service indefinitely by "After" clause?

Currently I am working on this issue: Service 1 is on another machine. Service 2 is on this machine but need Service 1 available to function. Service 3 is on this machine but need Service 2 to ...
George Y's user avatar
  • 560
0 votes
0 answers
1k views

Systemd service file location for locally-built software

This might be a mostly aesthetic problem, but it's been bugging me enough to put a little more effort into resolving it. In my work environment, we rely very heavily on in-house developed software for ...
Chris Robison's user avatar
0 votes
0 answers
1k views

Debian Failed at step EXEC spawning - Systems Service - Permission Denied

I'm following this tutorial exactly line by line: https://docs.meilisearch.com/learn/cookbooks/running_production.html#step-4-run-meilisearch-as-a-service It has a step to setup the Meilisearch as a ...
Jimmy's user avatar
  • 269
0 votes
1 answer
366 views

Systemd: why are files in /tmp or /run deleted after a few seconds?

I am using systemd to mount a Windows share using Kerberos. To make this work, I first run kinit in a .service file to create a Kerberos credential cache (ccache). The .service runs as root as the ...
Albert-Jan Roskam's user avatar
0 votes
1 answer
261 views

systemd string formatting for instance parameter

I'm trying to set up a systemd service that takes a parameter, and uses it in a couple places. I think I'm very close: with my config file name [email protected], I can run systemctl start myservice@...
ajwood's user avatar
  • 101
0 votes
1 answer
388 views

Custom systemd unit fails to start gnu screen and fork to background

I am trying to make systemd unit that starts a script inside GNU screen headlessly. I did base my work here on a couple of questions some had that were related. I also tested the ExecStart line in a ...
Kaizushi's user avatar
0 votes
0 answers
930 views

Ubuntu 20.04 Power LTS: How to disable "multipathd" service at boot time, from the petitboot shell?

Setup: I have large number of multipath LUNs from SAN, connected to this system. Most of these LUNs are not formatted for the Linux env and needs to be reformatted before using. The Problem: To work ...
hemanth kumar's user avatar
0 votes
0 answers
318 views

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 ...
Amandasaurus's user avatar
  • 32.3k
0 votes
0 answers
291 views

Systemctl reports service failed after user manually restarted Apache. Can systemd and reality be synched without restarting processes?

I have an Apache instance that starts with a systemd unit. A user manually stopped and restarted the instance. Now systemctl reports the service as "failed". Other than stopping and ...
iAmJeff's user avatar
  • 21
0 votes
0 answers
4k views

redhat linux 8 systemd service error 203

Deployed a sample dot net core web api to EC2 instance in /var/www/hello-app folder using the user “ec2-user” in FileZilla The folder contains the required dlls and other dotnet files Installed ...
Sudhir Jangam's user avatar