A tool that runs day and night sometimes posts crucial information to the wall. Is there any way to redirect this output to a file for when I'm asleep? Alternatively, does wall keep a log of messages posted to it or is there a way to enable it?
-
Apparently, there are some implementations of `wall` that write to `syslog`: https://linux.die.net/man/1/wall – Arkadiusz Drabczyk Sep 14 '19 at 17:55
-
And the implementation is here I think: https://salsa.debian.org/debian/sysvinit/blob/master/src/wall.c – Arkadiusz Drabczyk Sep 14 '19 at 18:15
-
@Arkadiusz please do add that as an answer. – roaima Sep 14 '19 at 18:39
-
@roaima: ok, I did – Arkadiusz Drabczyk Sep 14 '19 at 18:50
2 Answers
There are some implementations of wall that write to syslog, for
example http://salsa.debian.org/debian/sysvinit/blob/master/src/wall.c . In
its
manpage it
says:
For every invocation of wall a notification will be written to syslog, with facility LOG_USER and level BR LOG_INFO
If you cannot control application's behavior or tell it to use logger
instead of wall you can create a wall wrapper that would run a
regular wall command and use logger to write to syslog. You can
either create this wrapper in a new directory, add it to your $PATH
and restart program that uses wall with new $PATH settings or,
especially if you cannot even restart the program, replace system-wide
wall for everyone if you have enough permissions to do so. In this
example I will show you how to do the latter. First, rename existing
wall program to wall.orig:
$ command -v wall
/usr/bin/wall
$ sudo mv /usr/bin/wall /usr/bin/wall.orig
The new /usr/bin/wall wrapper script could look like this:
#!/usr/bin/env sh
# wall wrapper - run wall commands with specified arguments and write
# a notification to syslog
wall.orig "$@"
logger "wall was ran with the following options: $*, result: $?"
Remember to make it executable:
sudo chmod +x /usr/bin/wall
Use it like a regular wall:
$ wall "test message"
Broadcast message from ja@comp (pts/14) (Sat Sep 14 22:34:43 2019):
test message
If you have a working logger and syslogd is running you should see
the following message log in one of the files in /var/log that
syslogd is routing the messages to:
Sep 14 22:34:43 comp ja: wall was ran with the following options: test message, result: 0
Of course, keep in mind that each time you will upgrade your system
using its built-in upgrade mechanisms it's possible that the original
/usr/bin/wall binary will be restored again.
- 25,049
- 5
- 53
- 68
There is a logging level that will write to all logged in users with wall
logger -p emerg 'The sky is falling in'
The logger with write messages to the appropriate file under /var/log. For emergency priority messages it will also send them to users with wall.
- 25,049
- 5
- 53
- 68
- 107,089
- 14
- 139
- 261
-
It doesn't intercept messages posted to the wall though, does it? The tool that I mention, I don't control its behavior -- it always posts to the wall. The idea is to intercept these messages, write them to a file so that when I wake up I can examine it to see if anything happened during the night. – user75619 Sep 14 '19 at 19:46