0

On http://www.cs.newpaltz.edu/~easwaran/Resources/commands.html the following command is listed as being meant to "Refresh the syslog process":

kill -1 `cat /var/run/syslogd.pid`

I have seen this command in real-life use on an embedded device but I cannot wrap my mind around why someone would use it and how it works.

I understand the single parts this is made up off, but e.g. why is the cat subshell killed using a HUP signal is not something which makes sense to me.

2
  • What parts do you know? Do you know the purpose of kill? Do you know the purpose of kill -1? Do you know the purpose of cat? Do you know the purpose of /var/run/syslogd.pid? Do you know the purpose of backticks? I'm trying to find out how detailed an answer needs to be. Commented Dec 27, 2021 at 10:43
  • @KamilMaciorowski Edited my post. Commented Dec 27, 2021 at 10:53

1 Answer 1

1

syslogd would appear to do two things for the convenience of system administrators:

(a) If it is running, it posts its own pid (process id) in a well-known file. When it exits, it will attempt to remove this file.

(b) When it receives SIGHUP, it takes that as a hint that it should re-examine its configuration, because something might have changed recently. This is something of a convention: e.g. Unix cron daemons needed to be sent SIGHUP after a contab file was edited, to ensure any changes became effective.

3
  • The SIGHUP is directed torwards the cat command though and not syslogd Commented Dec 27, 2021 at 10:51
  • Not so. The cat command is enclosed in (old-school) back-ticks. This is a "process substitution" which shell runs first, and it emits the file contents, which is the pid number. This then gets substituted as the real arg to the kill process, like kill -1 2345. Commented Dec 27, 2021 at 10:54
  • Ah, of course! I am just not used to the backticks anymore that I forgot about how they work! Thanks. Commented Dec 27, 2021 at 10:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.