Public bug reported: 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. ** Affects: systemd (Ubuntu) Importance: Undecided Status: New -- You received this bug notification because you are a member of Ubuntu Touch seeded packages, 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: New 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 -- Mailing list: https://launchpad.net/~touch-packages Post to : touch-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~touch-packages More help : https://help.launchpad.net/ListHelp