• Re: differences between sysvinit and systemd; was: where is mail.log

    From Michael =?utf-8?B?S2rDtnJsaW5n?=@21:1/5 to All on Sat Nov 30 14:30:02 2024
    On 30 Nov 2024 20:33 +0800, from bitfox@secubox.org (Bitfox):
    May I ask what's the main difference between systemd and sysv for init system?

    I think it's fair to say that systemd does a great deal more, as well
    as that it brings things into the init system which have traditionally
    been done by separate pieces of software.

    SysV init is primarily a way to manage automated start and stop of
    services at runlevel changes, by executing a series of programs placed
    in magic directories (/etc/rc?.d) with specific parameters; and does
    very little else. Things like recovering from service failures,
    dependency management, etc. are up to those scripts (or the system administrator).

    Whereas systemd aims to be more of a system _management_ tool;
    bringing in system log storage, time synchronization, file system and
    service dependency management, on-demand service startup, network
    management, and a great deal more.

    A lot of people have very strong opinions about this.

    _From a user perspective_, there's actually not all that much
    difference: to get to a usable, running system, both systemd and
    sysvinit must accomplish roughly the same things and start the same
    services; and to interrogate the state of the running system, the
    administrator must do roughly the same things. The difference here is
    in _how_ this is accomplished and exactly which software is used for
    each part of it. Compatibility shims have also existed for a long
    time, and nothing really prevents for example a distribution from
    packaging /etc/init.d/* scripts which are wrappers around the
    corresponding systemctl commands on a systemd system.

    For example, whereas on a more traditional sysvinit system using
    traditional text-based log files, you might use something like

    # awk '{ if($5 ~ "^postfix[[]") { print } }' </var/log/messages

    on a systemd system you'd use, to roughly the same effect

    # journalctl --no-pager --all -u postfix

    (where -u xx can alternatively be written --unit=xx)

    and to restart a service, instead of SysV init's

    # /etc/init.d/postfix restart

    one might do

    # systemctl restart postfix

    --
    Michael Kjörling
    🔗 https://michael.kjorling.se

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to All on Sat Nov 30 15:10:01 2024
    On Sat, Nov 30, 2024 at 13:03:32 +0000, Michael Kjörling wrote:
    # awk '{ if($5 ~ "^postfix[[]") { print } }' </var/log/messages

    That's a rather verbose way of writing that awk command.

    awk '$5 ~ "^postfix[[]"' /var/log/messages

    Also, I'm quite new to postfix, but this pattern doesn't appear to match
    any lines in my log files. First of all, the lines in question seem to
    be in /var/log/syslog on Debian 10, not in messages. Second, they all
    look like:

    Nov 30 08:43:08 remote postfix/smtpd[5243]: connect from bendel.debian.org[82.195.75.100]

    and so on, with postfix followed by a slash, not a square bracket.
    Maybe your system is different, and therefore your logs are different.
    This is actually an endorsement for the systemd journal, where the
    lines in question are identified precisely by the unit/service name,
    and don't need to be matched by a questionable regular expression.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael =?utf-8?B?S2rDtnJsaW5n?=@21:1/5 to All on Sat Nov 30 16:50:01 2024
    On 30 Nov 2024 08:53 -0500, from greg@wooledge.org (Greg Wooledge):
    # awk '{ if($5 ~ "^postfix[[]") { print } }' </var/log/messages

    That's a rather verbose way of writing that awk command.

    awk '$5 ~ "^postfix[[]"' /var/log/messages

    Also, I'm quite new to postfix, but this pattern doesn't appear to match
    any lines in my log files. First of all, the lines in question seem to
    be in /var/log/syslog on Debian 10, not in messages. Second, they all
    look like:

    Nov 30 08:43:08 remote postfix/smtpd[5243]: connect from bendel.debian.org[82.195.75.100]

    and so on, with postfix followed by a slash, not a square bracket.

    So let me specifically highlight the "you might use something like"
    and "to roughly the same effect" relating to that example in my
    earlier post. What I wrote was not intended as a ready-to-use
    exact-equivalence one-or-the-other, but as an _illustrative example_.
    There are other differences between the two as well; one example of
    such a difference is how they handle log rotation, which is largely a
    non-issue with systemd + journalctl for the duration of log retention
    but requires particular care with *syslogd especially if log rotation
    also compresses old logs (as is typical), whereas passing journalctl
    --no-pager --all might not be typical but replicates the style of
    output from the awk example when run from an interactive terminal.

    --
    Michael Kjörling
    🔗 https://michael.kjorling.se

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)