XK0-005 · Question #475
A development team asks an engineer to guarantee the persistency of journal log files across system reboots. Which of the following commands would accomplish this task?
The correct answer is C. sed -i 's/auto/persistent/g' /etc/systemd/journald.conf && sed -i 'persistent/s/^#//q'. To ensure systemd journal logs persist across system reboots, the Storage parameter in /etc/systemd/journald.conf must be set to persistent and the systemd-journald service restarted.
Question
A development team asks an engineer to guarantee the persistency of journal log files across system reboots. Which of the following commands would accomplish this task?
Options
- Agrep -i auto /etc/systemd/journald.conf && systemctl restart systemd-journald.service
- Bcat /etc/systemd/journald.conf | awk '(print $1,$3)'
- Csed -i 's/auto/persistent/g' /etc/systemd/journald.conf && sed -i 'persistent/s/^#//q'
- Djournalctl --list-boots && systemctl restart systemd-journald.service
How the community answered
(34 responses)- A3% (1)
- B9% (3)
- C74% (25)
- D15% (5)
Why each option
To ensure systemd journal logs persist across system reboots, the `Storage` parameter in `/etc/systemd/journald.conf` must be set to `persistent` and the `systemd-journald` service restarted.
`grep -i auto /etc/systemd/journald.conf` only searches for the string 'auto' and does not modify the configuration for persistence.
`cat /etc/systemd/journald.conf | awk '(print $1,$3)'` merely displays parts of the configuration file and does not implement any changes to ensure log persistence.
The `sed -i 's/auto/persistent/g' /etc/systemd/journald.conf` command modifies the `journald.conf` file to change the `Storage` setting from `auto` to `persistent`, which configures systemd to store logs permanently on disk. The subsequent `sed -i 'persistent/s/^#//q'` command ensures that the `Storage=persistent` line is uncommented if it was previously commented out, making the setting active; restarting `systemd-journald.service` applies these changes.
`journalctl --list-boots` displays boot journal entries, which would be empty or incomplete if persistence is not configured, and restarting the service alone without configuration changes will not enable persistence.
Concept tested: systemd journal persistence configuration
Source: https://www.freedesktop.org/software/systemd/man/journald.conf.html
Topics
Community Discussion
No community discussion yet for this question.