1

As dhcpd negotiates it prints its output on the login prompt, which clutters (messes up, wrangles, uglifies, writes over, obscures [synonyms for googlers]) the console login prompt. How to inhibit dhcpd from outputting over the console login prompt?

Running Void Linux with runit, /etc/sv/dhcpd/run looks like this:

#!/bin/sh
[ -r conf ] && . ./conf
exec dhcpcd -B ${OPTS:=-M} 1>&2

/etc/sv/dhcpd/conf is empty.

3
  • redirect all outputs to dev null
    – Ijaz Ahmad
    Jun 28, 2016 at 11:10
  • @IjazKhan I'm looking for a way that would keep the output in the logs. Jun 28, 2016 at 12:37
  • Now tell answerers about your /etc/sv/dhcpd/log/ directory and its run program.
    – JdeBP
    Jun 28, 2016 at 17:29

2 Answers 2

2

I'm not sure why your dhcpcd isn't using syslog, as that's the default behavior of the utility (maybe Void Linux is using a special version). Anyway the output is going to the console because that's where the init manager sends its output, and unless redirected, applications started by the init manager inherit STDOUT & STDERR. Meaning the fix is to simply redirect the output.
Assuming you have a syslog daemon running on your system, I personally would change that script to something like:

#!/bin/bash
[ -r conf ] && . ./conf
exec dhcpcd -B ${OPTS:=-M} > >(exec logger -t dhcpd -p daemon.info) 2> >(exec logger -t dhcpd -p daemon.err)

This will send STDOUT output to syslog with the info level, and STDERR output to syslog with the err level.

2
  • This answer has missed the part of the question where the questioner points out that xe is using runit. This is an entirely wrongheaded way of doing this when using runit, and the statements about a purported "init manager" and its behaviour are just plain wrong for a runit system.
    – JdeBP
    Jun 29, 2016 at 7:38
  • @JdeBP Welcome to unix.stackexchange.com, if you think you have a better answer to the question, you're more than welcome to post it as a new answer. Also, linux has numerous different init systems, including ones like sysvinit, systemd, upstart, and in this case runit. An init manager is the process which is responsible for starting system level services.
    – phemmer
    Jun 29, 2016 at 12:27
0

Duncaen on #voidlinux at freenode gave me this link. Apparently this chaotic outputting comes from dmesg, not dhcpcd. Solution is to add dmesg -n 1 to /etc/rc.local.

1
  • This is very odd, as I think dmesg only affects messages from the kernel.
    – q.undertow
    Sep 26, 2020 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.