Questions tagged [systemd]

systemd is a modern replacement for the traditional Linux init. Its main features include the ability to express dependencies between services and aggressive parallelization of service startup.

systemd, created by Lennart Poettering and Kay Sievers, is a modern replacement for the traditional Linux init, whether System-V or BSD-style initscripts. Its main features include the ability to express dependencies between services and aggressive parallelization of service startup.

1525 questions
379
votes
6 answers

How to set environment variable in systemd service?

I have an Arch Linux system with systemd and I've created my own service. The configuration service at /etc/systemd/system/myservice.service looks like this: [Unit] Description=My…
lfagundes
  • 3,893
275
votes
2 answers

Do systemd unit files have to be reloaded when modified?

Let's say I write a mine.service file. Then I use systemctl enable mine.service. If I later decide to edit mine.service, do I have to tell systemd that mine.service was changed? If so, how do I do that?
425nesp
  • 2,992
  • 2
  • 13
  • 8
166
votes
4 answers

Find the location of a systemd unit file service

There are many different places where systemd unit files may be placed. Is there a quick and easy way to ask systemd where it read a service’s declaration from, given just the service name?
130
votes
4 answers

In systemd, what's the difference between After= and Requires=?

I'm creating a systemd .service file and I need help understanding the difference between Requires= and After=. The man page says that Requires= "Configures requirement dependencies on other units." and After= "Configures ordering dependencies…
TomOnTime
  • 8,131
82
votes
3 answers

Modify systemd unit file without altering upstream unit file

I have installed the pimd service by means of apt. This comes with an upstream systemd unit file (/lib/systemd/system/pimd.service). I want the service to be restarted when for some reason it gets killed, hence I wish to add the line Restart =…
giomanda
  • 1,824
59
votes
5 answers

systemd service automatic restart after StartLimitInterval

I want my systemd service to be automatically restarted on failure. Additionally I want to rate limit the restarts. I want to allow maximum of 3 restarts within 90 seconds duration. Hence I have done the following configuration. [Service] …
54
votes
3 answers

loginctl enable-linger/disable-linger ... but reading linger-status?

I know how to enable/disable lingering with loginctl. But up to now I found no way to query the status of a user. I want to know: Is lingering enable for user foo? How can I access this information?
guettli
  • 3,833
28
votes
4 answers

Systemd: Restart all instances of an Instantiated Service at once

I use the nice feature of systemd: Instantiated Services. Is there a simple way to reload all instantiated services with one call? Example: I don't want to run all like this: systemctl restart autossh@foo systemctl restart autossh@bar systemctl…
guettli
  • 3,833
23
votes
3 answers

How to debug systemd unit ExecStart

I am curious whether I can print out fully expanded ExecStart/ExecStop command line. Consider following example: ExecStart=/usr/bin/java $OPTS_COMMON $OPTS $OPTS_LOG $OPTS_DEBUG some.class.Start --param1 ${PARAM1} --param2 ${PARAM2} I am having…
pystole
  • 365
21
votes
3 answers

How to break complicated ExecStart line while still having comments in the middle?

I have a long command-line to put into a systemd ExecStart entry. I understand I can break a long line into multiple ones by ending each non-final line with a backslash. However, how can I document the parts with comments? E.g. the following won't…
20
votes
2 answers

Start systemd service conditionally?

At my organization we have a number of simple-to-use base AMIs for different services such as ECS and Docker. Since many of our projects involve CloudFormation, we're using cfn-bootstrap, which consists of a couple of scripts and a service which run…
Naftuli Kay
  • 1,728
18
votes
3 answers

reboot or "systemctl daemon-reload" for changes to /etc/systemd/system.conf?

Within CentOS-7 does a change in the options within /etc/systemd/system.conf of systemd require a reboot or will "systemctl daemon-reload" suffice?
18
votes
1 answer

Systemd timer not starting its service unit

Situation I have written a custom systemd service unit and its companion shell script to renew a certificate from Let's Encrypt. Everything works fine when I run systemctl start letsencrypt-example_com.service. I want it to be run automatically…
pandark
  • 486
15
votes
1 answer

What is SIGRTMIN+24 in syslog?

My Debian 8 vm has lots of systemd logs like this: Apr 28 23:02:09 foo systemd[22305]: Starting Shutdown. Apr 28 23:02:09 foo systemd[22305]: Reached target Shutdown. Apr 28 23:02:09 foo systemd[22305]: Starting Exit the Session... Apr 28 23:02:09…
artfulrobot
  • 3,119
14
votes
1 answer

Wait for service to gracefully exit before machine shutdown/reboot

How do you write a systemd service that gracefully shuts down upon machine shutdown or reboot? In particular, it should delay machine shutdown until it exits gracefully. I have a service that takes 10 seconds to shut down:…
yonran
  • 817
  • 2
  • 13
  • 22
1
2 3
11 12