Skip to content

Instantly share code, notes, and snippets.

@pydevops
Last active January 17, 2024 16:02
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pydevops/f5e8fba6071b11967851581ca0f44987 to your computer and use it in GitHub Desktop.
Save pydevops/f5e8fba6071b11967851581ca0f44987 to your computer and use it in GitHub Desktop.
systemd systemctl journalctl cheatsheet

Reference

show service unit file

systemctl cat <service>
systemctl list-units -t service
systemctl status chef-client

edit service unit

systemctl edit  --full google-ip-forwarding-daemon.service

logs


journalctl -u google-accounts-daemon.service

check which services for google

systemd-analyze blame: show a list of service has been loaded

#check its log
journalctl -u google-startup-scripts.service
# 
systemctl list-units --all --state=inactive | grep google
  google-instance-setup.service        loaded    inactive dead Google Compute Engine Instance Setup
  google-network-setup.service         loaded    inactive dead Google Compute Engine Network Setup
  google-startup-scripts.service       loaded    inactive dead Google Compute Engine Startup Scripts
  
systemctl list-unit-files | grep google
google-accounts-daemon.service         enabled
google-clock-skew-daemon.service       enabled
google-instance-setup.service          enabled
google-ip-forwarding-daemon.service    enabled
google-network-setup.service           enabled
google-shutdown-scripts.service        enabled
google-startup-scripts.service         enabled
  

systemd preset

/lib/systemd/system-preset 

90-google-compute-engine.preset  

enable google-accounts-daemon.service
enable google-clock-skew-daemon.service
enable google-instance-setup.service
enable google-ip-forwarding-daemon.service
enable google-network-setup.service
enable google-shutdown-scripts.service
enable google-startup-scripts.service

journalctl

journalctl -u kubelet
journalctl -u kubelet -f
journalctl -u kubelet --since today
systemctl status google-accounts-daemon.service
journalctl -u google-accounts-daemon.service -f
systemctl list-timers
NEXT                         LEFT       LAST                         PASSED       UNIT                         ACTIVATES
Tue 2018-01-16 23:20:46 UTC  19min left Mon 2018-01-15 23:20:46 UTC  23h ago      systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Tue 2018-01-16 23:55:36 UTC  54min left Tue 2018-01-16 22:55:36 UTC  5min ago     crash-sender.timer           crash-sender.service
Wed 2018-01-17 00:00:00 UTC  58min left Tue 2018-01-16 23:00:06 UTC  1min 13s ago kube-logrotate.timer         kube-logrotate.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment