sh script echo to syslog

Ernie Luzar luzar722 at
Wed Nov 8 21:53:05 UTC 2017

Polytropon wrote:
> On Wed, 08 Nov 2017 15:26:56 -0500, Ernie Luzar wrote:
>> Hello list;
>> I have a sh script that I use echo "message text" and it shows on the 
>> terminal console that started the script. Thats ok, but I would like to 
>> also have that same message posted the syslog.
> The easiest way is to use the "logger" command, for example:
> 	logger -t <scriptname> "<message text>"
> If you omit -t <name>, the user account under which the script
> runs will be logged; it's probably easier to use the scripts
> own identifier for this purpose. If you don't want it to be
> hard-coded, use this:
> 	logger -t `basename $0` "<message text>"
> Or with one external program call less:
> 	logger -t ${0##*/} "<message text>"
> That's probably the most convenient approach. :-)

Thanks to all who replied.

Logger was just what I needed.

More information about the freebsd-questions mailing list