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 <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.
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) [...]
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.
There have been package websites, which list packages and hint they
exist.
It's odd, but 'man -k daemon' turned up nothing (mint zara) ...
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)>.
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.
Mike Scott<usenet.16@scottsonline.org.uk.invalid> writes:
I've been using a program 'daemon' on freebsdIf you want an (almost) identical interface then in Debian (and
(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?
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
But the linux version seems to just keep writing to the same file
whatever I try.
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 freebsdIf you want an (almost) identical interface then in Debian (and
(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?
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?
On 2025-09-10, 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 freebsdIf you want an (almost) identical interface then in Debian (and
(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?
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) ?
On 10/09/2025 09:42, Dan Purgert wrote:
On 2025-09-10, Mike Scott wrote:Thanks for the reply, but no. That assumes the existence of the
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 freebsdIf you want an (almost) identical interface then in Debian (and
(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?
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) ?
mechanism missing AFAICS from this daemon.
On 2025-09-10, Mike Scott wrote:
On 10/09/2025 09:42, Dan Purgert wrote:
On 2025-09-10, Mike Scott wrote:Thanks for the reply, but no. That assumes the existence of the
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 freebsdIf you want an (almost) identical interface then in Debian (and
(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?
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) ?
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).
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:Thanks for the reply, but no. That assumes the existence of the
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 freebsdIf you want an (almost) identical interface then in Debian (and
(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?
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) ?
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.
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?
I'm not sure what you mean here. "Logrotate" is a tool that exists.
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--
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.
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.
On 10/09/2025 at 09:27, Lawrence D’Oliveiro wrote:
ITYF systemd doesn't use syslog - see journalctl.
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?
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:logrotate(8) ?
Mike Scott<usenet.16@scottsonline.org.uk.invalid> writes:
I've been using a program 'daemon' on freebsdIf you want an (almost) identical interface then in Debian (and
(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?
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?
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 <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:logrotate(8) ?
Mike Scott<usenet.16@scottsonline.org.uk.invalid> writes:
I've been using a program 'daemon' on freebsdIf you want an (almost) identical interface then in Debian (and
(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?
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?
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.
On Wed, 10 Sep 2025 12:04:48 +0100, Chris Elvidge wrote:
On 10/09/2025 at 09:27, Lawrence D’Oliveiro wrote:
ITYF systemd doesn't use syslog - see journalctl.
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?
systemd myth number 20: systemd makes it impossible to run syslog <https://0pointer.de/blog/projects/the-biggest-myths.html>.
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:logrotate(8) ?
Mike Scott<usenet.16@scottsonline.org.uk.invalid> writes:
I've been using a program 'daemon' on freebsdpresumably therefore also Ubuntu), there’s a command of the same name >>>>>> and similar behavior:
(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
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?
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.
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:
systemd myth number 20: systemd makes it impossible to run syslogITYF systemd doesn't use syslog - see journalctl.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?
<https://0pointer.de/blog/projects/the-biggest-myths.html>.
I didn't say it couldn't, just that it didn't.
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.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,069 |
Nodes: | 10 (0 / 10) |
Uptime: | 44:21:26 |
Calls: | 13,724 |
Files: | 186,959 |
D/L today: |
102 files (6,758K bytes) |
Messages: | 2,420,784 |