Advertisement
flycat

systemd, systemctl, journald, journalctl

May 27th, 2020 (edited)
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.11 KB | None | 0 0
  1. ###### Systemd unit example ######
  2. [Unit]
  3. Description=Server RZD
  4.  
  5. [Service]
  6. User=minidlna
  7. #Type=forking
  8. WorkingDirectory=/home/pi/ServerRZD/v1
  9. #ExecStartPre=
  10. ExecStart=/home/pi/ServerRZD/v1/srzd
  11. #ExecStartPost=
  12. ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
  13. Restart=always
  14. RemainAfterExit=yes
  15.  
  16. TimeoutSec=10
  17.  
  18. #### LOGGING:
  19. #Environment=PYTHONUNBUFFERED=1
  20. StandardOutput=tty
  21. #StandardOutput=syslog            # Output to syslog
  22. #StandardOutput=file:/home/user/log1.log
  23. #StandardError=append:/home/user/log2.log
  24. #StandardError=syslog             # Output to syslog
  25. #SyslogIdentifier=<your program identifier>
  26.  
  27. [Install]
  28. WantedBy=multi-user.target
  29.  
  30. ####################################
  31. Minimal unit runs rc.local at restart:
  32. [Unit]
  33. Description=Runs /usr/local/bin/rc.local
  34.  
  35. [Service]
  36. ExecStart=/usr/local/bin/rc.local
  37.  
  38. [Install]
  39. WantedBy=multi-user.target
  40. ####################################
  41. # systemd resolve
  42. # Show DNS status:
  43. resolvectl status
  44. systemd-resolve --statistics
  45.  
  46. # Clean DNS caches:
  47. systemd-resolve --flush-caches
  48. ####################################
  49.  
  50. # Disable not need services:
  51. for i in avahi-daemon wpa_supplicant bluealsa.service bluetooth.service alsa-restore.service hciuart.service ModemManager.service triggerhappy.service graphical.target rdnssd.service incron.service aakore.service acp-update-controller.service acronis_mms.service acronis_schedule.service active-protection.service unattended-upgrades.service cloud-init.service
  52. do
  53.  systemctl disable ${i}
  54.  systemctl stop ${i}
  55. done
  56. ##### User's units: https://wiki.archlinux.org/index.php/Systemd_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9)/User_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9)
  57.  
  58. # Current runlevel:
  59. systemctl get-default
  60.  
  61. # Get PID of unit:
  62. systemctl show --property MainPID --value speakphone
  63.  
  64. # View loaded targets:
  65. systemctl list-units --type target
  66. # View all targets:
  67. systemctl list-units --type target --all
  68. # View running units
  69. systemctl list-unit-files --state=disabled
  70.  
  71. # Journald /etc/systemd/journald.conf
  72. SystemMaxUse=1G
  73. systemctl restart systemd-journald.service
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement