[Touch-packages] [Bug 1810351] Re: journalctl fails to work inside systemd service

2021-06-30 Thread Dan Streetman
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
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:
  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  -o cat -n 20 | 
mail -s "Unit failed" '
  ExecStart=/bin/sh -c 'journalctl --user-unit= -o verbose -q -n 20 
| mail -s "Unit failed" '

  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


[Touch-packages] [Bug 1810351] Re: journalctl fails to work inside systemd service

2019-01-03 Thread Edward Gow
Part of the mystery is solved and part not.

SOLVED:

The problem was that journal entries were not being stored on disk and
journalctl was not showing entries from memory.

The default Ubuntu config has settings  
Storage=auto
SplitMode=uid

Also, the directory /var/log/journal does not exist by default and does
not get created in Storage=auto mode. Creating the /var/log/journal
directory and restarting journald so that entries get stored to disk
fixes the problem.


NOT SOLVED:

It is still unclear why journalctl would display output when run from
the shell but not when run from systemd. It would seem that in a systemd
--user unit it could not access the in-memory logs.


I would suggest that the default Ubuntu install should have the 
/var/log/journal directory in place so that journalctl will work correctly 
out-of-the-box.

-- 
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  -o cat -n 20 | 
mail -s "Unit failed" '
  ExecStart=/bin/sh -c 'journalctl --user-unit= -o verbose -q -n 20 
| mail -s "Unit failed" '

  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