• daemon program?

    From Mike Scott@usenet.16@scottsonline.org.uk.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 4 08:08:01 2025
    From Newsgroup: alt.os.linux.ubuntu

    Hi all.

    I've been using a program 'daemon' on freebsd
    (eg man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)

    which will run arbitrary programs as daemons, handling all the necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please?
    --
    Mike Scott
    Harlow, England

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Richard Kettlewell@invalid@invalid.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 4 08:26:45 2025
    From Newsgroup: alt.os.linux.ubuntu

    Mike Scott <usenet.16@scottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    (eg man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)

    which will run arbitrary programs as daemons, handling all the
    necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please?

    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name
    and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html

    If you want the housekeeping but don’t need to match the interface, your other option is to write a unit file and install it as a proper
    service. systemd will handle the housekeeping.
    --
    https://www.greenend.org.uk/rjk/
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mike Scott@usenet.16@scottsonline.org.uk.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 4 08:38:08 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott <usenet.16@scottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    (eg
    man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)

    which will run arbitrary programs as daemons, handling all the
    necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please?

    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name
    and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html

    If you want the housekeeping but don’t need to match the interface, your other option is to write a unit file and install it as a proper
    service. systemd will handle the housekeeping.


    Many thanks. It's odd, but 'man -k daemon' turned up nothing (mint
    zara), nor did a web search (too many matches perhaps saying what
    daemons do). But it does seem to be available to apt (sudo apt install
    daemon)
    --
    Mike Scott
    Harlow, England
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Dan Purgert@dan@djph.net to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 4 09:22:15 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 2025-09-04, Mike Scott wrote:
    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott <usenet.16@scottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    [...]
    I can't find a ready-to-roll linux version - is there one please?

    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name
    and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html
    [...]

    Many thanks. It's odd, but 'man -k daemon' turned up nothing (mint
    zara) [...]

    That's not surprising -- the "entirety" of manpages aren't installed by default, just the ones relevant to those applications that are
    installed.
    --
    |_|O|_|
    |_|_|O| Github: https://github.com/dpurgert
    |O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1 E067 6D65 70E5 4CE7 2860
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Paul@nospam@needed.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 4 06:12:11 2025
    From Newsgroup: alt.os.linux.ubuntu

    On Thu, 9/4/2025 5:22 AM, Dan Purgert wrote:
    On 2025-09-04, Mike Scott wrote:
    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott <usenet.16@scottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    [...]
    I can't find a ready-to-roll linux version - is there one please?

    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name
    and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html
    [...]

    Many thanks. It's odd, but 'man -k daemon' turned up nothing (mint
    zara) [...]

    That's not surprising -- the "entirety" of manpages aren't installed by default, just the ones relevant to those applications that are
    installed.


    # Some of this is material from the Notes file, that has been
    # sitting there for eons. These are necessitated by religion issues.
    # Various parts of this may appear to be unnecessary (on your particular distro).

    sudo add-apt-repository universe # If these are already present, the software will tell you
    sudo add-apt-repository multiverse
    sudo apt-get update # On live media, this step may fail depending on how old the media is

    apt search daemon | less # In the worst case, will return a lot of (local) results
    # You don't need to be root, to search for stuff.

    sudo apt install daemon # Will put the manual page on local disk
    man daemon # Read the manual page.

    sudo apt install synaptic # Package Manager
    sudo synaptic # Run the Package Manager, search for Daemon
    # Do "Properties" on the line you find. It will list
    # the file manifest. This helps with packages where the
    # executable has a different name than the package (gddrescue, executable is ddrescue).

    There have been package websites, which list packages and hint they exist.
    Teh Google does not always return such sites today.

    A Google search such as

    linux man listdir

    should give a manual page as the first or second result.

    This is for the benefit of new users. In some cases, even the Terminal is
    hard to find, but that's a whole nother post.

    Paul
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 4 20:54:28 2025
    From Newsgroup: alt.os.linux.ubuntu

    On Thu, 4 Sep 2025 06:12:11 -0400, Paul wrote:

    There have been package websites, which list packages and hint they
    exist.

    packages.debian.org being an obvious one for Debian.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Fri Sep 5 04:05:35 2025
    From Newsgroup: alt.os.linux.ubuntu

    On Thu, 4 Sep 2025 08:38:08 +0100, Mike Scott wrote:

    It's odd, but 'man -k daemon' turned up nothing (mint zara) ...

    Should have at least turned up the standard C library routine <https://manpages.debian.org/daemon(3)>.

    Note the warning there about its behaviour, though.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Richard Kettlewell@invalid@invalid.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Fri Sep 5 08:16:20 2025
    From Newsgroup: alt.os.linux.ubuntu

    Lawrence D’Oliveiro <ldo@nz.invalid> writes:
    On Thu, 4 Sep 2025 08:38:08 +0100, Mike Scott wrote:
    It's odd, but 'man -k daemon' turned up nothing (mint zara) ...

    Should have at least turned up the standard C library routine <https://manpages.debian.org/daemon(3)>.

    Only if manpages-dev is installed, which isn’t necessarily the case.
    --
    https://www.greenend.org.uk/rjk/
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Fri Sep 5 07:55:50 2025
    From Newsgroup: alt.os.linux.ubuntu

    On Fri, 05 Sep 2025 08:16:20 +0100, Richard Kettlewell wrote:

    Lawrence D’Oliveiro <ldo@nz.invalid> writes:

    On Thu, 4 Sep 2025 08:38:08 +0100, Mike Scott wrote:

    It's odd, but 'man -k daemon' turned up nothing (mint zara) ...

    Should have at least turned up the standard C library routine
    <https://manpages.debian.org/daemon(3)>.

    Only if manpages-dev is installed, which isn’t necessarily the case.

    Ah. True, but surely any self-respecting developer would have done
    that. ;)
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mike Scott@usenet.16@scottsonline.org.uk.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 09:01:15 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott<usenet.16@sc
    ottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    (eg
    man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)

    which will run arbitrary programs as daemons, handling all the
    necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please?
    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name
    and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html

    Sorry, back again.

    I've been playing with this and there seems to be an important feature
    missing on linux that's in the BSD version: how to do logfile rotation?

    BSD offers:
    -H Close output_file and re-open it when signal SIGHUP is
    received,
    for interoperability with newsyslog(1) and similar log
    rotation /
    archival mechanisms. If -o is not specified, this flag is
    ignored.


    But the linux version seems to just keep writing to the same file
    whatever I try. The only workaround seems to be to kill both the daemon
    and its child, move the log file, and restart them. Seems a bit clumsy.

    Have I missed something?

    Thanks.
    --
    Mike Scott
    Harlow, England
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 08:27:35 2025
    From Newsgroup: alt.os.linux.ubuntu

    On Wed, 10 Sep 2025 09:01:15 +0100, Mike Scott wrote:

    But the linux version seems to just keep writing to the same file
    whatever I try.

    Aren’t you supposed to do logging through syslog?
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Dan Purgert@dan@djph.net to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 08:42:26 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 2025-09-10, Mike Scott wrote:
    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott<usenet.16@sc
    ottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    (eg
    man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)

    which will run arbitrary programs as daemons, handling all the
    necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please?
    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name
    and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html

    Sorry, back again.

    I've been playing with this and there seems to be an important feature missing on linux that's in the BSD version: how to do logfile rotation?
    [...]
    Have I missed something?

    logrotate(8) ?
    --
    |_|O|_|
    |_|_|O| Github: https://github.com/dpurgert
    |O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1 E067 6D65 70E5 4CE7 2860
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mike Scott@usenet.16@scottsonline.org.uk.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 10:20:08 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 10/09/2025 09:42, Dan Purgert wrote:
    On 2025-09-10, Mike Scott wrote:
    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott<usenet.16@sc
    ottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    (eg
    man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)

    which will run arbitrary programs as daemons, handling all the
    necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please?
    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name
    and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html

    Sorry, back again.

    I've been playing with this and there seems to be an important feature
    missing on linux that's in the BSD version: how to do logfile rotation?
    [...]
    Have I missed something?

    logrotate(8) ?


    Thanks for the reply, but no. That assumes the existence of the
    mechanism missing AFAICS from this daemon.

    And to answer ldo, this is for a web daemon that writes its own private
    log file that needs archival copies kept; syslog is not appropriate.
    I've been doing that using mv and sending the BSD daemon a sighup;
    migration is being something of a chore.

    Looks like I'll have to see about patching the daemon source code.
    --
    Mike Scott
    Harlow, England
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Dan Purgert@dan@djph.net to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 09:37:30 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 2025-09-10, Mike Scott wrote:
    On 10/09/2025 09:42, Dan Purgert wrote:
    On 2025-09-10, Mike Scott wrote:
    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott<usenet.16@sc
    ottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    (eg
    man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)

    which will run arbitrary programs as daemons, handling all the
    necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please?
    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name >>>> and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html

    Sorry, back again.

    I've been playing with this and there seems to be an important feature
    missing on linux that's in the BSD version: how to do logfile rotation?
    [...]
    Have I missed something?

    logrotate(8) ?


    Thanks for the reply, but no. That assumes the existence of the
    mechanism missing AFAICS from this daemon.

    I'm not sure what you mean here. "Logrotate" is a tool that exists.

    Granted, the systems here have been getting in-place upgrades for the
    last decade; maybe logrotate has since been replaced in 'clean' installs
    (or it's not a default part of the installation and I've just completely forgotten that).
    --
    |_|O|_|
    |_|_|O| Github: https://github.com/dpurgert
    |O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1 E067 6D65 70E5 4CE7 2860
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Theo@theom+news@chiark.greenend.org.uk to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 11:08:28 2025
    From Newsgroup: alt.os.linux.ubuntu

    In uk.comp.os.linux Dan Purgert <dan@djph.net> wrote:
    On 2025-09-10, Mike Scott wrote:
    On 10/09/2025 09:42, Dan Purgert wrote:
    On 2025-09-10, Mike Scott wrote:
    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott<usenet.16@sc
    ottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    (eg
    man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)

    which will run arbitrary programs as daemons, handling all the
    necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please?
    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name >>>> and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html

    Sorry, back again.

    I've been playing with this and there seems to be an important feature >>> missing on linux that's in the BSD version: how to do logfile rotation? >>> [...]
    Have I missed something?

    logrotate(8) ?


    Thanks for the reply, but no. That assumes the existence of the
    mechanism missing AFAICS from this daemon.

    I'm not sure what you mean here. "Logrotate" is a tool that exists.

    Granted, the systems here have been getting in-place upgrades for the
    last decade; maybe logrotate has since been replaced in 'clean' installs
    (or it's not a default part of the installation and I've just completely forgotten that).

    It sounds like the problem is that 'daemon' is never closing the output
    file, so 'logrotate' is never able to process it. The -H flag is supposed
    to tell daemon to close the file on SIGHUP so logrotate can swap it out, but
    it doesn't exist in the Debian version.

    This is the source to the FreeBSD version: https://github.com/freebsd/freebsd-src/tree/main/usr.sbin/daemon

    - maybe the 'sighup' feature could be merged into the Debian version?

    Theo
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Dan Purgert@dan@djph.net to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 10:54:07 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 2025-09-10, Theo wrote:
    In uk.comp.os.linux Dan Purgert <dan@djph.net> wrote:
    On 2025-09-10, Mike Scott wrote:
    On 10/09/2025 09:42, Dan Purgert wrote:
    On 2025-09-10, Mike Scott wrote:
    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott<usenet.16@sc
    ottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    (eg
    man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)

    which will run arbitrary programs as daemons, handling all the
    necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please?
    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name >> >>>> and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html

    Sorry, back again.

    I've been playing with this and there seems to be an important feature >> >>> missing on linux that's in the BSD version: how to do logfile rotation? >> >>> [...]
    Have I missed something?

    logrotate(8) ?


    Thanks for the reply, but no. That assumes the existence of the
    mechanism missing AFAICS from this daemon.

    I'm not sure what you mean here. "Logrotate" is a tool that exists.

    Granted, the systems here have been getting in-place upgrades for the
    last decade; maybe logrotate has since been replaced in 'clean' installs
    (or it's not a default part of the installation and I've just completely
    forgotten that).

    It sounds like the problem is that 'daemon' is never closing the output
    file, so 'logrotate' is never able to process it. The -H flag is supposed
    to tell daemon to close the file on SIGHUP so logrotate can swap it
    out, but it doesn't exist in the Debian version.

    Oh, then you add 'copytruncate' to the rotate directives, and the
    original log gets zeroed out when logrotate runs.
    --
    |_|O|_|
    |_|_|O| Github: https://github.com/dpurgert
    |O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1 E067 6D65 70E5 4CE7 2860
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Chris Elvidge@chris@internal.net to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 12:04:48 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 10/09/2025 at 09:27, Lawrence D’Oliveiro wrote:
    On Wed, 10 Sep 2025 09:01:15 +0100, Mike Scott wrote:

    But the linux version seems to just keep writing to the same file
    whatever I try.

    Aren’t you supposed to do logging through syslog?


    ITYF systemd doesn't use syslog - see journalctl.

    Perhaps run the daemon via systemd, or install (r)syslog + logrotate
    --
    Chris Elvidge, England
    MY HOMEWORK WAS NOT STOLEN BY A ONE-ARMED MAN
    Bart Simpson on chalkboard in episode 1F11

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mike Scott@usenet.16@scottsonline.org.uk.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 12:20:31 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 10/09/2025 10:37, Dan Purgert wrote:
    I'm not sure what you mean here. "Logrotate" is a tool that exists.

    logrotate assumes the target can close and re-open its log. Witness,
    from the man page, a config file entry:

    "/var/log/httpd/access.log" /var/log/httpd/error.log {
    rotate 5
    mail recipient@example.org
    size 100k
    sharedscripts
    postrotate
    /usr/bin/killall -HUP httpd
    endscript
    }

    The point being the target does its own close and reopen, often, as
    here, with a sighup.

    If the target can't do this somehow, bets are off. All logrotate does is schedule things, and handle the renaming; it has no magic to close and
    reopen someone else's file.

    The 'daemon' program seems to have no way of cooperating with any
    external (non-brute) force to achieve this.
    --
    Mike Scott
    Harlow, England
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mike Scott@usenet.16@scottsonline.org.uk.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 12:25:32 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 10/09/2025 11:08, Theo wrote:
    It sounds like the problem is that 'daemon' is never closing the output
    file, so 'logrotate' is never able to process it. The -H flag is supposed
    to tell daemon to close the file on SIGHUP so logrotate can swap it out, but it doesn't exist in the Debian version.

    Absolutely the problem.

    I'm years out of practice with writing C, but it looks a manageable job
    to add the necessary code. Might take me a while though.


    This is the source to the FreeBSD version: https://github.com/freebsd/freebsd-src/tree/main/usr.sbin/daemon

    - maybe the 'sighup' feature could be merged into the Debian version?


    If I can do it, I'll see about getting the changes merged in to the
    original.


    Theo
    --
    Mike Scott
    Harlow, England
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Dan Purgert@dan@djph.net to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 11:31:51 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 2025-09-10, Mike Scott wrote:
    On 10/09/2025 10:37, Dan Purgert wrote:
    I'm not sure what you mean here. "Logrotate" is a tool that exists.

    logrotate assumes the target can close and re-open its log.

    By default, sure; but there are options to deal with it.


    copytruncate
    Truncate the original log file to zero size in place after cre-
    ating a copy, instead of moving the old log file and optionally
    creating a new one. It can be used when some program cannot be
    told to close its logfile and thus might continue writing (ap-
    pending) to the previous log file forever. Note that there is a
    very small time slice between copying the file and truncating
    it, so some logging data might be lost. When this option is
    used, the create option will have no effect, as the old log file
    stays in place. The copytruncate option allows storing rotated
    log files on the different devices using olddir directive. The
    copytruncate option implies norenamecopy.
    --
    |_|O|_|
    |_|_|O| Github: https://github.com/dpurgert
    |O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1 E067 6D65 70E5 4CE7 2860
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mike Scott@usenet.16@scottsonline.org.uk.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 16:52:28 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 10/09/2025 12:31, Dan Purgert wrote:
    On 2025-09-10, Mike Scott wrote:
    On 10/09/2025 10:37, Dan Purgert wrote:
    I'm not sure what you mean here. "Logrotate" is a tool that exists.

    logrotate assumes the target can close and re-open its log.

    By default, sure; but there are options to deal with it.


    copytruncate
    Truncate the original log file to zero size in place after cre-
    ating a copy, instead of moving the old log file and optionally
    creating a new one. It can be used when some program cannot be
    told to close its logfile and thus might continue writing (ap-
    pending) to the previous log file forever. Note that there is a
    very small time slice between copying the file and truncating
    it, so some logging data might be lost. When this option is
    used, the create option will have no effect, as the old log file
    stays in place. The copytruncate option allows storing rotated
    log files on the different devices using olddir directive. The
    copytruncate option implies norenamecopy.


    logrotate is a new one to me, and I didn't see this on a quick glance at
    the man page; thanks for pointing it out. There's no freebsd equivalent
    AFAIK, where newsyslog does the equivalent job.

    I'm not sure about the potential data loss that's noted in the man page.
    I dislike anything that can fail unexpectedly and lose data.

    Anyway, I have made the alteration to the daemon program itself. My
    version looks for SIGUSR2, which will close and reopen the log files
    without any data loss.

    Good to have a choice though, so thanks for the helpful reply.
    --
    Mike Scott
    Harlow, England
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Wed Sep 10 19:32:39 2025
    From Newsgroup: alt.os.linux.ubuntu

    On Wed, 10 Sep 2025 12:04:48 +0100, Chris Elvidge wrote:

    On 10/09/2025 at 09:27, Lawrence D’Oliveiro wrote:

    On Wed, 10 Sep 2025 09:01:15 +0100, Mike Scott wrote:

    But the linux version seems to just keep writing to the same file
    whatever I try.

    Aren’t you supposed to do logging through syslog?

    ITYF systemd doesn't use syslog - see journalctl.

    systemd myth number 20: systemd makes it impossible to run syslog <https://0pointer.de/blog/projects/the-biggest-myths.html>.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Richard Kettlewell@invalid@invalid.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 11 08:49:04 2025
    From Newsgroup: alt.os.linux.ubuntu

    Mike Scott <usenet.16@scottsonline.org.uk.invalid> writes:
    On 10/09/2025 09:42, Dan Purgert wrote:
    On 2025-09-10, Mike Scott wrote:
    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott<usenet.16@sc
    ottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    (eg
    man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)

    which will run arbitrary programs as daemons, handling all the
    necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please?
    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name >>>> and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html

    Sorry, back again.

    I've been playing with this and there seems to be an important feature
    missing on linux that's in the BSD version: how to do logfile rotation?
    [...]
    Have I missed something?
    logrotate(8) ?

    Thanks for the reply, but no. That assumes the existence of the
    mechanism missing AFAICS from this daemon.

    And to answer ldo, this is for a web daemon that writes its own
    private log file that needs archival copies kept; syslog is not
    appropriate. I've been doing that using mv and sending the BSD daemon
    a sighup; migration is being something of a chore.

    Looks like I'll have to see about patching the daemon source code.

    I’m not quite clear on the requirement here. I think what you mean is:

    * The daemon executable logs to stdout and/or stderr
    * You want these logs saved to a file
    * You want this file rotated (in the normal way for a logfile)
    * You want to keep the data essentially indefinitely, or at least, for
    longer than other syslog outputs.

    I can see several options.

    1) Change the daemon to log to the target file instead of stdout/stderr,
    and either arrange for it to close and re-open the logfile when it
    recieves SIGHUP, or just do the log rotate itself (which avoids
    dealing with signal handlers).

    2) Add a second program that reads from stdin and writes to the target
    logfile, doing the log rotation itself. The daemon command line would
    be a pipeline, e.g. daemon sh -c "executable 2>&1 | loghandler".

    3) Log to syslog, either directly or via the daemon wrapper. syslog
    daemons (e.g. rsyslogd) can select a specific program’s logs to an
    individual file, and you can control the log rotation policy for that
    file individually. The syslog daemon takes care of the close/re-open
    dance.
    --
    https://www.greenend.org.uk/rjk/
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mike Scott@usenet.16@scottsonline.org.uk.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 11 11:02:30 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 11/09/2025 08:49, Richard Kettlewell wrote:
    Mike Scott <usenet.16@scottsonline.org.uk.invalid> writes:
    On 10/09/2025 09:42, Dan Purgert wrote:
    On 2025-09-10, Mike Scott wrote:
    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott<usenet.16@sc
    ottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    (eg
    man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)

    which will run arbitrary programs as daemons, handling all the
    necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please?
    If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name >>>>> and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html

    Sorry, back again.

    I've been playing with this and there seems to be an important feature >>>> missing on linux that's in the BSD version: how to do logfile rotation? >>>> [...]
    Have I missed something?
    logrotate(8) ?

    Thanks for the reply, but no. That assumes the existence of the
    mechanism missing AFAICS from this daemon.

    And to answer ldo, this is for a web daemon that writes its own
    private log file that needs archival copies kept; syslog is not
    appropriate. I've been doing that using mv and sending the BSD daemon
    a sighup; migration is being something of a chore.

    Looks like I'll have to see about patching the daemon source code.

    I’m not quite clear on the requirement here. I think what you mean is:

    * The daemon executable logs to stdout and/or stderr
    * You want these logs saved to a file
    * You want this file rotated (in the normal way for a logfile)
    * You want to keep the data essentially indefinitely, or at least, for
    longer than other syslog outputs.

    I can see several options.

    1) Change the daemon to log to the target file instead of stdout/stderr,
    and either arrange for it to close and re-open the logfile when it
    recieves SIGHUP, or just do the log rotate itself (which avoids
    dealing with signal handlers).

    2) Add a second program that reads from stdin and writes to the target
    logfile, doing the log rotation itself. The daemon command line would
    be a pipeline, e.g. daemon sh -c "executable 2>&1 | loghandler".

    3) Log to syslog, either directly or via the daemon wrapper. syslog
    daemons (e.g. rsyslogd) can select a specific program’s logs to an
    individual file, and you can control the log rotation policy for that
    file individually. The syslog daemon takes care of the close/re-open
    dance.


    The problem is fixed to my satisfaction, but to answer your query.

    The target program runs unattended for extended periods. It writes a lot
    of data to stdout and stderr. It is not of itself a daemon in the linux
    sense, just a large chunk of perl code that normally runs at a terminal.
    To make it a self-contained linux daemon would be a pain, and pointless duplication of code. At user-determined intervals, I need output to be directed to a fresh file.

    On freebsd, I've been using a program called 'daemon'. This runs the
    target program as a child process, intercepting its stdout and stderr
    and writing their data to a suitable file; it also does the necessary detaching and other housekeeping operations on its behalf. Importantly, 'daemon' responds to a suitable signal by closing and reopening its
    output. This provides a way of chopping up the target program's output
    streams into files for archiving and further processing without stopping it.

    The linux program of the same name does much the same - but lacks the
    ability to close and reopen its output files. 'logrotate' can sort-of
    work around this with a (small) risk of data loss for programs like
    mine, that cannot handle rotation hygienically.

    I've now modified the linux 'daemon' program to respond as the freebsd
    one, and it can now close and reopen its output file(s) without risk of
    data loss. So archiving now becomes a simple matter of "mv log.txt
    log.old; kill -usr2 <daemon-pid>" which results in log.old with the data
    to date, and a fresh log.txt being opened.

    I've emailed the author to see if he's interested in rolling the
    modification into the next release.

    And yes, I suppose your suggestion #2 would have worked. But involving a
    3rd program is messy, and I'd still be having cut code to tell it to do
    the log rotation on request. Better to put that where it really belongs,
    I think. But thanks for the idea.
    --
    Mike Scott
    Harlow, England
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Chris Elvidge@chris@internal.net to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 11 13:46:35 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 10/09/2025 at 20:32, Lawrence D’Oliveiro wrote:
    On Wed, 10 Sep 2025 12:04:48 +0100, Chris Elvidge wrote:

    On 10/09/2025 at 09:27, Lawrence D’Oliveiro wrote:

    On Wed, 10 Sep 2025 09:01:15 +0100, Mike Scott wrote:

    But the linux version seems to just keep writing to the same file
    whatever I try.

    Aren’t you supposed to do logging through syslog?

    ITYF systemd doesn't use syslog - see journalctl.

    systemd myth number 20: systemd makes it impossible to run syslog <https://0pointer.de/blog/projects/the-biggest-myths.html>.


    I didn't say it couldn't, just that it didn't.
    --
    Chris Elvidge, England
    ALL WORK AND NO PLAY MAKES BART A DULL BOY
    Bart Simpson on chalkboard in episode 1F07

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Chris Elvidge@chris@internal.net to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 11 13:53:09 2025
    From Newsgroup: alt.os.linux.ubuntu

    On 11/09/2025 at 11:02, Mike Scott wrote:
    On 11/09/2025 08:49, Richard Kettlewell wrote:
    Mike Scott <usenet.16@scottsonline.org.uk.invalid> writes:
    On 10/09/2025 09:42, Dan Purgert wrote:
    On 2025-09-10, Mike Scott wrote:
    On 04/09/2025 08:26, Richard Kettlewell wrote:
    Mike Scott<usenet.16@sc
    ottsonline.org.uk.invalid> writes:
    I've been using a program 'daemon' on freebsd
    (eg
    man.freebsd.org/cgi/man.cgi?query=daemon&sektion=8&manpath=FreeBSD+14.3-RELEASE+and+Ports)


    which will run arbitrary programs as daemons, handling all the
    necessary "house-keeping" for them.

    I can't find a ready-to-roll linux version - is there one please? >>>>>> If you want an (almost) identical interface then in Debian (and
    presumably therefore also Ubuntu), there’s a command of the same name >>>>>> and similar behavior:

    https://manpages.debian.org/trixie/daemon/daemon.1.en.html

    Sorry, back again.

    I've been playing with this and there seems to be an important feature >>>>> missing on linux that's in the BSD version: how to do logfile
    rotation?
    [...]
    Have I missed something?
    logrotate(8) ?

    Thanks for the reply, but no. That assumes the existence of the
    mechanism missing AFAICS from this daemon.

    And to answer ldo, this is for a web daemon that writes its own
    private log file that needs archival copies kept; syslog is not
    appropriate. I've been doing that using mv and sending the BSD daemon
    a sighup; migration is being something of a chore.

    Looks like I'll have to see about patching the daemon source code.

    I’m not quite clear on the requirement here. I think what you mean is:

    * The daemon executable logs to stdout and/or stderr
    * You want these logs saved to a file
    * You want this file rotated (in the normal way for a logfile)
    * You want to keep the data essentially indefinitely, or at least, for
    longer than other syslog outputs.

    I can see several options.

    1) Change the daemon to log to the target file instead of stdout/stderr,
    and either arrange for it to close and re-open the logfile when it
    recieves SIGHUP, or just do the log rotate itself (which avoids
    dealing with signal handlers).

    2) Add a second program that reads from stdin and writes to the target
    logfile, doing the log rotation itself. The daemon command line would
    be a pipeline, e.g. daemon sh -c "executable 2>&1 | loghandler".

    3) Log to syslog, either directly or via the daemon wrapper. syslog
    daemons (e.g. rsyslogd) can select a specific program’s logs to an
    individual file, and you can control the log rotation policy for that
    file individually. The syslog daemon takes care of the close/re-open
    dance.


    The problem is fixed to my satisfaction, but to answer your query.

    The target program runs unattended for extended periods. It writes a lot
    of data to stdout and stderr. It is not of itself a daemon in the linux sense, just a large chunk of perl code that normally runs at a terminal.
    To make it a self-contained linux daemon would be a pain, and pointless duplication of code. At user-determined intervals, I need output to be directed to a fresh file.

    On freebsd, I've been using a program called 'daemon'. This runs the
    target program as a child process, intercepting its stdout and stderr
    and writing their data to a suitable file; it also does the necessary detaching and other housekeeping operations on its behalf. Importantly, 'daemon' responds to a suitable signal by closing and reopening its
    output. This provides a way of chopping up the target program's output streams into files for archiving and further processing without stopping
    it.

    The linux program of the same name does much the same - but lacks the ability to close and reopen its output files. 'logrotate' can sort-of
    work around this with a (small) risk of data loss for programs like
    mine, that cannot handle rotation hygienically.

    I've now modified the linux 'daemon' program to respond as the freebsd
    one, and it can now close and reopen its output file(s) without risk of
    data loss. So archiving now becomes a simple matter of "mv log.txt
    log.old; kill -usr2 <daemon-pid>" which results in log.old with the data
    to date, and a fresh log.txt being opened.

    I've emailed the author to see if he's interested in rolling the modification into the next release.

    And yes, I suppose your suggestion #2 would have worked. But involving a
    3rd program is messy, and I'd still be having cut code to tell it to do
    the log rotation on request. Better to put that where it really belongs,
    I think. But thanks for the idea.




    Have you seen 'daemonize' - seems to do what you want.
    --
    Chris Elvidge, England
    ALL WORK AND NO PLAY MAKES BART A DULL BOY
    Bart Simpson on chalkboard in episode 1F07

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Richard Kettlewell@invalid@invalid.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 11 18:48:51 2025
    From Newsgroup: alt.os.linux.ubuntu

    Chris Elvidge <chris@internal.net> writes:
    Lawrence D’Oliveiro wrote:
    On Wed, 10 Sep 2025 12:04:48 +0100, Chris Elvidge wrote:
    On 10/09/2025 at 09:27, Lawrence D’Oliveiro wrote:
    On Wed, 10 Sep 2025 09:01:15 +0100, Mike Scott wrote:

    But the linux version seems to just keep writing to the same file
    whatever I try.

    Aren’t you supposed to do logging through syslog?

    ITYF systemd doesn't use syslog - see journalctl.
    systemd myth number 20: systemd makes it impossible to run syslog
    <https://0pointer.de/blog/projects/the-biggest-myths.html>.

    I didn't say it couldn't, just that it didn't.

    In the context of a question about “logging through syslog”, it _does_
    use syslog. journald listens on /dev/log and the syslog(3) API works.
    --
    https://www.greenend.org.uk/rjk/
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to uk.comp.os.linux,alt.os.linux.ubuntu on Thu Sep 11 22:17:21 2025
    From Newsgroup: alt.os.linux.ubuntu

    On Thu, 11 Sep 2025 11:02:30 +0100, Mike Scott wrote:

    The target program runs unattended for extended periods. It writes a
    lot of data to stdout and stderr. It is not of itself a daemon in
    the linux sense, just a large chunk of perl code that normally runs
    at a terminal. To make it a self-contained linux daemon would be a
    pain, and pointless duplication of code.

    It shouldn’t take much work to make it runnable as a daemon. Remember,
    the distinction in *nix isn’t that great, anyway: look at common
    existing service daemons, and you will see that lots of them will run
    fine in non-daemon mode, specifically to ease debugging.
    --- Synchronet 3.21a-Linux NewsLink 1.2