[Bug 1810351] Re: journalctl fails to work inside systemd service
Dan Streetman
1810351 at bugs.launchpad.net
Wed Jun 30 22:17:25 UTC 2021
please reopen if this is still an issue
** Changed in: systemd (Ubuntu)
Status: New => Invalid
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to systemd in Ubuntu.
https://bugs.launchpad.net/bugs/1810351
Title:
journalctl fails to work inside systemd service
Status in systemd package in Ubuntu:
Invalid
Bug description:
Using
Ubuntu 16.04.4 LTS
and
Package: systemd
Architecture: amd64
Version: 229-4ubuntu21.10
Multi-Arch: foreign
Priority: required
Section: admin
Origin: Ubuntu
The journalctl(1) command cannot be used in a systemd OnFailure
service to get error logs. To replicate the issue
1) Create a service unit
[Unit]
Description=%n
[Service]
#ExecStart=/bin/sh -xv -c 'systemctl --user status <your unit> -o cat -n 20 | mail -s "Unit failed" <your email address>'
ExecStart=/bin/sh -c 'journalctl --user-unit=<your unit> -o verbose -q -n 20 | mail -s "Unit failed" <your email address>'
2) enable the unit
3) start the unit
You will get a failure message from journalctl and mail of
sh[28225]: No journal files were opened due to insufficient permissions.
sh[28225]: mail: Null message body; hope that's ok
4) switch the comment # to the journalctl ExecStart and uncomment the
systemctl ExecStart line
From systemctl you will get journal output in the email.
The man page for systemctl states "In addition, journalctl
--unit=NAME or journalctl --user-unit=NAME use a similar filter for
messages and might be more convenient." and indeed it would if it
worked properly.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1810351/+subscriptions
More information about the foundations-bugs
mailing list