0

i found documentation for logger stating one can use --id=$$ to log the pid of the calling script. unfortunatly this is not working with logger in centos7.

what is the proper way of logging pid to syslog in centos7?

  • Could you give a bit more context, such as where/how you are calling logger? What are you seeing in the resulting logs? Is there no PID, or the 'wrong' PID? – iwaseatenbyagrue Mar 15 '17 at 12:46
  • sorry - should have included that in my initial post - i call "logger --id=$$ some msg" and i get "logger: option '--id' doesn't allow an argument" – user3347114 Mar 15 '17 at 12:57

1 Answers1

0

Your issues seems to be down a slight difference in what the man page you link to says is supported, and what your logger actually supports.

I just checked a centOS7 system, and I can replicate your issue:

$ sudo logger --help

Usage:
 logger [options] [message]

Options:
 -T, --tcp             use TCP only
 -d, --udp             use UDP only
 -i, --id              log the process ID too
 <snip>

$ sudo logger --id=11 test
logger: option '--id' doesn't allow an argument

So on centOS7, logger will only allow you to include (or not) the PPID, it does not allow you to set the PID to something arbitrary.

So logger --id some msg will NOT work, and is NOT equivalent to what logger --id=$$ some msg would have done.

I should have checked the output more thoroughly before suggesting it was, thanks @user3347114 for correcting me.

iwaseatenbyagrue
  • 3,688
  • 15
  • 24
  • unfortunatly "logger --id some msg" is not equivalent to "logger --id=$$ some msg" - the pid logger writes is not the same as the pid of the calling process - therefore every invocation of logger within the same script logs with a different PID. that makes the whole idea of logging the PID pretty useless.... – user3347114 Mar 15 '17 at 17:09