Questions tagged [systemd-service]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
18 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 ...
  • 1,138
1 vote
0 answers
14 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&...
  • 2,282
0 votes
1 answer
26 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 myservice@.service, I can run systemctl start myservice@...
  • 101
0 votes
1 answer
30 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 ...
0 votes
0 answers
154 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 ...
0 votes
0 answers
35 views

Auditd service mysteriously stopped after 2 minutes on Ubuntu

ubuntu:~$ systemctl status auditd ● auditd.service - Security Auditing Service Loaded: loaded (/lib/systemd/system/auditd.service; enabled; vendor preset: enabled) Active: inactive (dead) since ...
  • 1
0 votes
0 answers
14 views

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 ...
0 votes
0 answers
210 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 ...
  • 101
0 votes
0 answers
187 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 ...
  • 30.5k
0 votes
0 answers
120 views

systemd: my service stopped working with code=killed

My service has suddenly stopped working, systemctl status reports: Main PID: 5459 (code=killed, signal=TERM) Also, I checked through ``journald for my service (journalctl -u myservice.service`) and ...
  • 209
0 votes
0 answers
154 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 ...
  • 21
0 votes
1 answer
468 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 ...
1 vote
0 answers
813 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....
1 vote
1 answer
1k 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: ●...
3 votes
1 answer
1k 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 ...
  • 145
0 votes
0 answers
2k 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 ...
1 vote
1 answer
220 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 ...
4 votes
2 answers
6k 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:/...
0 votes
1 answer
2k 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 ...
0 votes
1 answer
150 views

nginx.service is not starting after mount

I have a nginx that depends on a mounted drive. My nginx.service has an entry with the RequiresMountsFor in the service unit like this: [Unit] RequiresMountsFor=/media/bar But looks like it is still ...
0 votes
1 answer
234 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 ...
1 vote
2 answers
1k 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 ...
  • 216
0 votes
2 answers
359 views

Howto create custom service in systemd?

Running Fedora 33/34 on multiple machines. I successfully activated rc-local.service which works fine. I have couple of other scripts that I need to run in /etc/init.d/ and I created similar service ...
  • 23
1 vote
1 answer
5k 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 ...
  • 187
2 votes
2 answers
3k 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 ...
1 vote
2 answers
1k 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 ...
  • 43
1 vote
0 answers
64 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 ...
3 votes
1 answer
23k 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 ...
  • 141
0 votes
2 answers
8k 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/...
0 votes
1 answer
276 views

Using find -exec in systemd ExecStartPre

I think it's fairly obvious what I'm trying to do here # Rename Log File ExecStartPre=/bin/find /data/db/log/*.log -type f -exec mv {} {}.`date +"%Y%m%d-%H%M"` \; # gzip past log files (is ...
  • 1
0 votes
1 answer
161 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 ...
  • 101
0 votes
1 answer
385 views

Systemd: Unlock drives before ZFS import

I have LUKS encrypted drives and ZFS on top of that. I unlock the drives on boot using a script. I made a systemd service for that, but the script take some time and the zfs-import-cache.service ...
  • 336
0 votes
1 answer
2k 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 ...
  • 121
2 votes
0 answers
1k 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....
0 votes
2 answers
734 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 ...
  • 669
0 votes
1 answer
359 views

systemd service fails to authenticate scp between two servers

I have written a service that triggers a shell script to backup a postgres database, on a CentOS7 server. It dumps the backup file into the /tmp/ folder and then it is supposed to copy the file across ...
  • 111
2 votes
1 answer
257 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 ping@.timer sudo systemctl enable ping@service sudo systemctl start ping@hello....
  • 41
1 vote
1 answer
2k 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?
4 votes
2 answers
6k 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 ...
  • 30.5k