Difference between revisions of "Systemd"

From gr0x0rd
Jump to navigation Jump to search
(Created page with "Systemd is a different animal from the old days of init.d. Each service has a unit, and depending on the name of the unit, you can use systemd to enable, start, stop, disable...")
 
 
Line 14: Line 14:
 
  $ sudo journalctl -u <unit>
 
  $ sudo journalctl -u <unit>
 
It's possible to trim the output using filters. This is necessary and sufficient for problematic services. To see all entries since a specific time
 
It's possible to trim the output using filters. This is necessary and sufficient for problematic services. To see all entries since a specific time
  $ journalctl -u <unit> --since "2022-08-30 14:10:10"  
+
  $ sudo journalctl -u <unit> --since "2022-08-30 14:10:10"  
 
To view all entries withing a specific timeframe
 
To view all entries withing a specific timeframe
  $ journalctl -u <unit> --since "2022-08-30 14:10:10" --until "2022-08-30 14:20:10"
+
  $ sudo journalctl -u <unit> --since "2022-08-30 14:10:10" --until "2022-08-30 14:20:10"

Latest revision as of 09:51, 17 May 2022

Systemd is a different animal from the old days of init.d. Each service has a unit, and depending on the name of the unit, you can use systemd to enable, start, stop, disable or check the status of a service.

Checking the status of a service

$ sudo systemctl status <unit>

Adding a service to startup

$ sudo systemctl enable <unit>

Starting a service

$ sudo systemctl start <unit>

Stopping a service

$ sudo systemctl stop <unit>

Disabling a service

$ sudo systemctl disable <unit>

Checking service logs

The logs reset and accumulate after system startup. So if your machine has been running for a long time, or the service has generated a lot of logs, you might be dealing with a lot of information when checking the logs. To do so use the journalctl directive.

$ sudo journalctl -u <unit>

It's possible to trim the output using filters. This is necessary and sufficient for problematic services. To see all entries since a specific time

$ sudo journalctl -u <unit> --since "2022-08-30 14:10:10" 

To view all entries withing a specific timeframe

$ sudo journalctl -u <unit> --since "2022-08-30 14:10:10" --until "2022-08-30 14:20:10"