Skip to content

Commit

Permalink
something new: 2024-04-07 12:13:33
Browse files Browse the repository at this point in the history
  • Loading branch information
pew committed Apr 7, 2024
1 parent 6366b88 commit e2c4f0b
Showing 1 changed file with 63 additions and 62 deletions.
125 changes: 63 additions & 62 deletions man/systemd.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
date created: Monday, April 22nd 2019, 6:51:17 pm
date modified: Saturday, August 5th 2023, 3:57:24 pm
date modified: Sunday, April 7th 2024, 12:13:29 pm
tags:
- systemd
- systemctl
- linux
title: systemd
---

Expand All @@ -25,45 +26,6 @@ output example:
2min 158ms systemd-networkd-wait-online.service
```

## logs / systemd journals

### log disk usage

check current disk usage of systemd journals:

```shell
journalctl --disk-usage
```

clean up some old logs:

```shell
journalctl --vacuum-size=100M
```

### configure journal / log usage

it might be a good idea to limit the disk usage of your systemd journals. To do this, edit the file: `/etc/systemd/journald.conf`

**control how much disk space the journal may use up at most**:

```
SystemMaxUse=1G
```

**control how large individual journal files may grow at most**:

```
SystemMaxFileSize=100M
```

and restart things

```shell
systemctl daemon-reload # for good measure
systemctl restart systemd-journald.service
```

## DNS

all things DNS
Expand Down Expand Up @@ -101,6 +63,14 @@ sudo systemctl restart systemd-resolved.service

verify again (see above)

### change hostname

```shell
sudo hostnamectl set-hostname my-awesome-host
```

depending on your setup you might still need to update your `/etc/hosts` file as well

### clear dns cache

```shell
Expand All @@ -113,30 +83,49 @@ verify:
resolvectl statistics
```

## change hostname
## logs: journalctl / systemd journals

```shell
sudo hostnamectl set-hostname my-awesome-host
```
### configure journal / log usage

depending on your setup you might still need to update your `/etc/hosts` file as well
it might be a good idea to limit the disk usage of your systemd journals. To do this, edit the file: `/etc/systemd/journald.conf`

## timers (better cronjobs!)
**control how much disk space the journal may use up at most**:

todo.. write something somewhere about the use of systemd-timers instead of cronjobs.
```
SystemMaxUse=1G
```

### list timers
**control how large individual journal files may grow at most**:

```
systemctl list-timers
SystemMaxFileSize=100M
```

### disable timer
and restart things

```shell
systemctl disable name.timer
systemctl daemon-reload # for good measure
systemctl restart systemd-journald.service
```

### log disk usage

check current disk usage of systemd journals:

```shell
journalctl --disk-usage
```

clean up some old logs:

```shell
journalctl --vacuum-size=100M
```

## timers (better cronjobs!)

todo.. write something somewhere about the use of systemd-timers instead of cronjobs.

### create your own timer / cronjob

**create your service unit:**
Expand Down Expand Up @@ -181,23 +170,21 @@ systemctl daemon-reload
systemctl enable restic_backup.timer
```

## working with services

### list active services

the service might be *active*, but exited already since it was just initializing or checking something
### disable timer

```shell
systemctl list-units --type=service --state=active
systemctl disable name.timer
```

### list running services
### list timers

```shell
systemctl list-units --type=service --state=running
```
systemctl list-timers
```

## logs / debugging
## working with services

### debugging: read and follow service logs output

**read logs**:

Expand All @@ -207,6 +194,20 @@ journalctl -u your-name.service

**tail log**:

```
```shell
journalctl -f -u your-name.service
```

### list active services

the service might be *active*, but exited already since it was just initializing or checking something

```shell
systemctl list-units --type=service --state=active
```

### list running services

```shell
systemctl list-units --type=service --state=running
```

0 comments on commit e2c4f0b

Please sign in to comment.