Understanding syslogd

can someone explain what the following line of code does

/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true


and how does it differ from

test -f /var/run/syslogd.pid && kill -HUP `cat /var/run/syslogd.pid`


[I know it should restart syslogd, but is there any difference between the two? Linux noob bit sorry]


source to share

2 answers

  • /bin/kill -HUP <PID>

    - sends a SIGHUP signal for processing identified by <PID>

    (process id). Sending this signal to daemons (or services, if you prefer) usually instructs them to re-read (read again) their config
  • cat /var/run/syslogd.pid 2> /dev/null

    - reads a file /var/run/syslogd.pid

    (containing the PID of the syslogd daemon ) and prints it to standard output (file descriptor = 0

    (zero)). The part 2> /dev/null

    redirects the standard error stream (file descriptor = 2

    (two)) to /dev/null

    to discard all error messages that occur while reading/var/run/syslogd.pid

  • test -f /var/run/syslogd.pid

    - checks if the file exists /var/run/syslogd.pid

    . If it exists (usually), it means that the daemon (in this case syslogd ) is up and running.


  • The first command means: send a SIGHUP to syslogd discard all error messages and return true if they completed successfully.
  • The second command means: if the syslogd daemon is running, send a SIGHUP
  • /dev/null

    is a special device file that discards (ignores) everything that is written on it (for example, a bottomless well). Sometimes used to throw away error messages (like in your case here).


the second command is used to check if a file named /var/run/syslog.pid exists, this file stores the pid for the current syslog service, the second part of the command will kill this process



All Articles