Difference between revisions of "Systemd"

From DWIKI
m
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:


 
 


= Documentation =
= Documentation =
Line 15: Line 16:
*[[https://blog.darknedgy.net/technology/2020/05/02/0/index.html#tech-critique https://blog.darknedgy.net/technology/2020/05/02/0/index.html#tech-critique]  
*[[https://blog.darknedgy.net/technology/2020/05/02/0/index.html#tech-critique https://blog.darknedgy.net/technology/2020/05/02/0/index.html#tech-critique]  
*[https://mohsensy.github.io/sysadmin/2018/08/19/systemd-service-tutorial.html Systemd service tutorial]  
*[https://mohsensy.github.io/sysadmin/2018/08/19/systemd-service-tutorial.html Systemd service tutorial]  
 
*[https://www.freedesktop.org/wiki/Software/systemd/dbus/ https://www.freedesktop.org/wiki/Software/systemd/dbus/ Systemd and dbus]
([https://www.thegeekdiary.com/how-to-boot-into-rescue-mode-or-emergency-mode-through-systemd-in-centos-rhel-7-and-8/ Single user/emergency]
*[https://www.thegeekdiary.com/how-to-boot-into-rescue-mode-or-emergency-mode-through-systemd-in-centos-rhel-7-and-8/ Single user/emergency]


= Locations =
= Locations =
Line 25: Line 26:


 
 
=HOWTO=
==Timers==
==Show active timers==
systemctl status *timer




= HOWTO =
== Timers ==
*[https://opensource.com/article/20/7/systemd-timers https://opensource.com/article/20/7/systemd-timers]
*[https://wiki.archlinux.org/title/Systemd/Timers https://wiki.archlinux.org/title/Systemd/Timers]
man systemd.timer
=== List active timers ===


systemctl list-timers
=== List all timers ===
systemctl list-timers --all
=== Create timer ===
systemctl enable fstrim.timer
== Auto restart crashed services ==
systemctl edit elasticsearch.service
add:
[Service]
Restart=always
then
systemctl daemon-reload
systemctl restart elasticsearch.service
And to get an email when service gets restarted: https://dev.to/setevoy/linux-systemd-unit-files-edit-restart-on-failure-and-email-notifications-5h3k


= FAQ =
= FAQ =
== Fix journal size ==
journalctl --vacuum-time=10d
or
journalctl --vacuum-size=1G
===Journal settings===
/etc/systemd/journald.conf
SystemMaxUse=1G
and then
systemctl restart systemd-journald.service


== Analyze boot processes ==
== Analyze boot processes ==


  systemd-analyze blame
  systemd-analyze blame
 
 


 
 
Line 44: Line 92:


  resolvectl status
  resolvectl status
=== Failed to get global data: Unit dbus-org.freedesktop.resolve1.service not found. ===
Means systemd-resolved is not running


Restart:
Restart:


  systemctl restart systemd-resolved
  systemctl restart systemd-resolved
     
     
 
=== Add nameserver ===
Sacrifice a chicken
 
=== Flush caches ===
systemd-resolve --flush-caches


== All status ==
== All status ==
Line 82: Line 148:


  systemctl daemon-reexec
  systemctl daemon-reexec
==Status==
=== Active: inactive (dead) ===
parameter ActiveState would return inactive
SubState returns dead

Latest revision as of 20:36, 20 May 2022

 


Documentation

Locations

/etc/systemd
/usr/lib/systemd/
/lib/systemd

 


HOWTO

Timers

man systemd.timer

List active timers

systemctl list-timers


List all timers

systemctl list-timers --all

Create timer

systemctl enable fstrim.timer

Auto restart crashed services

systemctl edit elasticsearch.service 

add:

[Service]
Restart=always

then

systemctl daemon-reload
systemctl restart elasticsearch.service

And to get an email when service gets restarted: https://dev.to/setevoy/linux-systemd-unit-files-edit-restart-on-failure-and-email-notifications-5h3k

FAQ

Fix journal size

journalctl --vacuum-time=10d

or

journalctl --vacuum-size=1G

Journal settings

/etc/systemd/journald.conf

SystemMaxUse=1G

and then

systemctl restart systemd-journald.service


Analyze boot processes

systemd-analyze blame

 

 

 

Systemd and DNS

resolvectl status

Failed to get global data: Unit dbus-org.freedesktop.resolve1.service not found.

Means systemd-resolved is not running

Restart:

systemctl restart systemd-resolved
      
      

 

Add nameserver

Sacrifice a chicken

 

Flush caches

systemd-resolve --flush-caches

All status

systemctl status -a

syslog spam

https://psyq123.wordpress.com/2015/06/29/if-you-get-a-lot-of-logspam-from-systemd-in-your-varlogsyslog-this-might-help/

list available services

systemctl list-unit-files

or

systemctl list-units

 

normal interface names

net.ifnames=0

Show failed services

systemctl --failed

 

systemd: Started Session

Change loglevel to notice in /etc/systemd/system.conf

systemctl daemon-reexec

Status

Active: inactive (dead)

parameter ActiveState would return inactive

SubState returns dead