Hacker News new | ask | show | jobs
by calvinmorrison 1333 days ago
Already happened to me, I have less and less idea how my linux system works now. I haven't kept up with all the various systemd rewrites, buses and random shit I don't know about and it's annoying when I actually want to do something

has journalctl -xe ever dumped any useful information for anyone ever or am I just an idiot? when I restart nginx I want to know if it failed, why , what's the syntax error. instead old reliable /etc/init.d/nginx configtest no I have to dig around

6 comments

Here's an excerpt from my cheat sheet:

    # Output all logs since boot
    journalctl
    # Follow all logs in real time
    journalctl -f
    # Output logs for a given systemd unit
    journalctl -u $unit
    # Combine follow and unit flags to follow logs for a given systemd unit
    # Easy to remember: You are saying F*** U to a broken piece of software
    journalctl -fu $unit
    # Output kernel logs
    journalctl -k
    # Follow kernel logs
    journalctl -fk

    # Tip: Use -b flag to see logs from previous boot cycles

    # Learn more, including advanced filtering and formatting
    man journalctl
You can also add that configtest command as an ExecStartPre to the unit, and it will run that before starting nginx and optionally fail early if it finds an error.
You forgot:

    # Easy to remember: You are saying F**K because your kernel is broken
    journalctl -fk
Thank You
> has journalctl -xe ever dumped any useful information for anyone ever

It can be useful when there's potentially multiple things leading up to the error in whatever you're running, as it is showing and explaining nearly every action that's recently happened in the system log. But if you're just wanting to look at logs related to nginx starting at the most recent then just query for niginx's system log instead of the whole system.

    sudo journalctl --pager-end --unit nginx
or:

    sudo journalctl -e -u nginx
or:

    sudo journalctl -eu nginx
If a process or service is using systemd to start and stop it (e.g. You start it with `systemctl start $SERVICE_NAME), I often do `systemctl status $SERVICE_NAME` to get the service-specific logs. For me, it seems to get the job done much better than journalctl.
If you can set up nginx to do what you want, you can learn how to use systemd. In my experience it is quite usable once you get a handle on it. I'm sure there are plenty of "getting started" kinds of introductions that could make it useful to you after maybe half an hour of time investment. Other commenters have answered your specific question.
systemd is aliased to /usr/sbin/service, so old sysvinit commands still work:

  $ service nginx status
which should cover your

  if it failed, why , what's the syntax error
For anything more complicated, refer to these cheatsheets:

https://wiki.archlinux.org/title/Systemd#Using_units

https://wiki.archlinux.org/title/Systemd/Journal#Filtering_o...

YMMV. I find systemd a lot easier to work with (I actually started wrapping daemons in proper services instead of sticking everything into nohup or tmux sessions).

Then use a distro that doesn't use systemd.
Right, then I have to relearn my userspace setup... well maybe it's time - but I've been on debian longer long before I met my childs mother, before I even grew a single hair on my chest, before I had a bank account, a job, or a cell phone. But perhaps you are right, it's time to quit it
MX Linux (Debian-based, uses sysvinit with systemd shims) and Devuan would seem to be obvious alternatives that wouldn't require changes to your setup.
I'll check it out. I have all sorts of weirdness with this system. snap is great because debian doesn't package a lot, yet then all my snap programs are sandboxed in a non useful way. (like mysqlworkbench won't save passwords in a keystore because that hookup doesn't work - and it cant run without a working keystore. like firefox will start once, but if you run the firefox command, it'll error out that firefox is already) lots of annoying little things
Debian runs without systemd fine, at least for me.

Try trinity as a desktop with sysvinit.

I am a big fan of trinity! I have it for the unbeatable KDE 3 konqueror and a few other choice apps.
Yes, a well run / nice project. KDE3 seems far better than anything in the KDE or Gnome world since.

(I don't use kwin, but instead a different window manager, and only part of trinity for this and that, but that's not due to a lack of quality, I just prefer to mix and match.)