{"id":327,"date":"2014-02-12T05:26:38","date_gmt":"2014-02-12T03:26:38","guid":{"rendered":"http:\/\/log.or.cz\/?p=327"},"modified":"2019-10-19T14:13:07","modified_gmt":"2019-10-19T12:13:07","slug":"systemd-journal-listing-on-devtty12","status":"publish","type":"post","link":"https:\/\/log.or.cz\/?p=327","title":{"rendered":"systemd: journal listing on \/dev\/tty12"},"content":{"rendered":"<p>Inspired by the Debian CTTE <a href=\"http:\/\/aceattorney.sparklin.org\/jeu.php?id_proces=57684\">deli<\/a><a href=\"http:\/\/aceattorney.sparklin.org\/jeu.php?id_proces=57899\">bera<\/a><a href=\"https:\/\/news.ycombinator.com\/item?id=7203364\">tions<\/a> on the new default init for Debian, <a href=\"https:\/\/lists.debian.org\/debian-devel\/2014\/02\/msg00539.html\">I installed systemd<\/a> on my notebook after tonight&#8217;s forced reboot and played with it a little.<\/p>\n<p>(And I like it! I was very sceptical when hearing about systemd first, but after reading a lot of discussions and trying it myself, I find most of the problematic points either fixed already or a load of FUD. The immediate big selling point for me is actually journald, it and its integration with systemctl is really awesome. I&#8217;ll actually find systemd more useful on servers than desktops, I think.)<\/p>\n<p>While it&#8217;s a nice exercise for anyone wanting to get familiar with systemd, I still decided to share a tidbit &#8211; service file that will make log entries show up on \/dev\/tty12. Many people run with rsyslogd set up for this, you&#8217;ll want to disable that (by default, all journal entries are forwarded to rsyslog). The advantage of showing journal entries instead is mainly color coding. :)<\/p>\n<p>The file listing follows, or <a href=\"http:\/\/pasky.or.cz\/dev\/systemd\/journal@tty12.service\">get it here<\/a>.<\/p>\n<pre># Simple systemd service that will show journal contents on \/dev\/tty12\n# by running journalctl -af on it.\n# Install by:\n#  - Saving this as \/etc\/systemd\/system\/journal@tty12.service\n#  - Running systemctl enable journal@tty12\n#  - Running systemctl start journal@tty12\n# journald can also log on console itself, but current Debian version won't\n# show timestamps and color-coding.\n# systemd is under LGPL2.1 etc, this is inspired by getty@.service.\n\n[Unit]\nDescription=Journal tail on %I\nDocumentation=man:journalctl(1)\nAfter=systemd-user-sessions.service plymouth-quit-wait.service systemd-journald.service\nAfter=rc-local.service\n\n# On systems without virtual consoles, don't start any getty. (Note\n# that serial gettys are covered by serial-getty@.service, not this\n# unit\nConditionPathExists=\/dev\/tty0\n\n[Service]\n# the VT is cleared by TTYVTDisallocate\nExecStart=\/bin\/sh -c \"exec \/bin\/journalctl -af &gt; \/dev\/%I 2&gt; \/dev\/%I\"\nType=idle\nRestart=always\nRestartSec=1\nUtmpIdentifier=%I\nTTYPath=\/dev\/%I\nTTYReset=yes\nTTYVHangup=yes\n#TTYVTDisallocate=yes\nTTYVTDisallocate=no\nKillMode=process\nIgnoreSIGPIPE=no\n\n# Unset locale for the console getty since the console has problems\n# displaying some internationalized messages.\nEnvironment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=\n\n[Install]\nAlias=getty.target.wants\/journal@tty12.service\n<\/pre>\n<p>(P.S.: Creating this service file &#8211; my very first one &#8211; took me 10 minutes total, including studying documentation and debugging two stupid mistakes I made.)<\/p>\n<p><strong>Edit (2019-10-19):\u00c2\u00a0<\/strong>New versions of journalctl check their stderr to decide whether to use colorize output &#8211; I have updated the recipe accordingly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Inspired by the Debian CTTE deliberations on the new default init for Debian, I installed systemd on my notebook after tonight&#8217;s forced reboot and played with it a little. (And I like it! I was very sceptical when hearing about systemd first, but after reading a lot of discussions and trying it myself, I find [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[8,130,129],"class_list":["post-327","post","type-post","status-publish","format-standard","hentry","category-linux","tag-debian","tag-journald","tag-systemd"],"_links":{"self":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/327","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=327"}],"version-history":[{"count":6,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/327\/revisions"}],"predecessor-version":[{"id":484,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/327\/revisions\/484"}],"wp:attachment":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}