Questions tagged [systemd]

Systemd is a system management daemon designed for Linux. Use this tag for *programming questions* using systemd or its libraries. Questions about *configuring the daemon* (including writing unit files) are better directed to Unix & Linux: https://unix.stackexchange.com.

Systemd is a system management daemon designed for Linux and programmed exclusively for the Linux API. For systems using it, it is the first process which is executed in user space during the Linux startup process. Therefore, systemd serves as the root of the user space's process tree.

2384 questions
22
votes
2 answers

Cannot disable systemd serial-getty service

On Raspberry Pi with Arch Linux there is a service active called serial-getty@AMA0. The unit file is: /usr/lib/systemd/system/serial-getty@.service As root I can invoke systemctl stop serial-getty@ttyAMA0 systemctl disable serial-getty@ttyAMA0 But…
lojoe
  • 521
  • 1
  • 3
  • 13
21
votes
3 answers

Can't detach child process when main process is started from systemd

I want to spawn long-running child processes that survive when the main process restarts/dies. This works fine when running from the terminal: $ cat exectest.go package main import ( "log" "os" "os/exec" "syscall" …
monkey snow
  • 581
  • 1
  • 4
  • 10
21
votes
2 answers

How to define a d-bus activated systemd service?

Does anyone have an example, or a link to an example of how to define a systemd .service which is activated by d-bus? My understanding is that if I create a test.service file here: /usr/share/dbus-1/services/test.service With the following…
RandomUser
  • 4,140
  • 17
  • 58
  • 94
21
votes
2 answers

Test if a systemd unit is active in a bash script

I'm writing a script to automatically install a bind server on a CentOs 7 distribution. I'm stuck with systemctl status, because it does not produce an error code (it's right, since a status is not an error) I can use. What I want is to check…
math
  • 311
  • 1
  • 2
  • 3
20
votes
6 answers

Prevent forwarding of systemd service logs to syslog without affecting other service logs sent to syslog

My computer runs serveral java processes as systemd services.The systemd logs get accumulated in the syslog eventually leading to low disk space . How to re-direct the logs started by systemd services towards /dev/null so that it does not accumulate…
achilles
  • 536
  • 5
  • 16
20
votes
4 answers

set umask for tomcat8 via tomcat.service

I am trying to set a custom umask for a tomcat 8 instance, tried to make it the good way by using the UMask directive in systemd tomcat unit as seen here without luck. I'd like to set a 022 umask cause the company dev needs to access tomcat /…
Pier
  • 618
  • 2
  • 8
  • 23
20
votes
8 answers

Unable to start postgresql.service?

I'm using arch linux (4.8.13-1-ARCH). I'm trying to set up PostgreSQL as instructed here. After performing [postgres@BitBox ~]$ initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data' The files belonging to this database system will be owned by…
code_master5
  • 701
  • 1
  • 8
  • 18
20
votes
3 answers

How stop systemd service

I am trying to create systemd service file for Flume, have created /etc/systemd/system/flume-ng.service with following contents [Unit] Description=Apache Flume [Service] Environment=FLUME_CLASSPATH=/opt/flume/current/lib/ ExecStart=/usr/bin/nohup…
roy
  • 6,344
  • 24
  • 92
  • 174
20
votes
1 answer

Systemd http health check

I have a service on a Redhat 7.1 which I use systemctl start, stop, restart and status to control. One time the systemctl status returned active, but the application "behind" the service responded http code different from 200. I know that I can use…
clausfod
  • 315
  • 1
  • 3
  • 7
19
votes
2 answers

Systemd: Using both After and Requires

I have a service foo.service which depends on service bar.service. I need to make sure that bar.service is started before foo.service and that bar.service launched successfully. From this source it says that Requires: This directive lists any units…
flakes
  • 21,558
  • 8
  • 41
  • 88
18
votes
4 answers

systemd: start service at boot time after network is really up (for WoL purpose)

I have a computer at work which I sometimes wakeup from home in order to access it but when boots and gets another IP address from our DHCP server, how can I access it? The situation and my “workflow” is as follows: From my home PC I connect to the…
PerlDuck
  • 5,610
  • 3
  • 20
  • 39
18
votes
2 answers

How do I list all systemd masked units?

Is there an easy way to list all systemd masked units? I can think of: ls -l /etc/systemd/system/* | grep /dev/null Or (for unit names only): ls -l /etc/systemd/system/* | grep /dev/null | cut -d' ' -f12 | awk -F'/' '{ print $(NF) }' Is there a…
ilstam
  • 1,473
  • 4
  • 18
  • 32
18
votes
2 answers

Is there any way to list systemd services in linux "in-the-order-of" they were loaded?

I am trying to understand the dependencies between different systemd services in my new project. We are using yocto build system and systemd/system services. If I perform, systemctl -l It will list all the services in alphabetic order. But I am…
user3128488
  • 367
  • 1
  • 2
  • 7
18
votes
3 answers

How to use Systemd to restart a service when down?

On my server I use elasticSearch which regularly goes down and the result is a 500 error for my users. I understand Systemd is now the reference for managing services. How can I use Systemd to restart my elastic search service automatically when it…
Sébastien
  • 5,263
  • 11
  • 55
  • 116
17
votes
2 answers

using sudo with ExecStart (systemd)

I am trying to get a node.js site live on port 80 (I am using Digital Ocean). I doing this using systemd with in service file ... ExecStart=/usr/bin/nodejs /var/www/bin/app.js ... On localhost this works fine on port 80 if I use sudo to start the…
Mike
  • 3,775
  • 8
  • 39
  • 79