#!/bin/bash
# https://urbanautomaton.com/blog/2014/09/09/redirecting-bash-script-output-to-syslog/
exec 1> >(logger -s -t $(basename $0) 2>&1)
for i in 1 2 3 4 5
do
echo "Welcome $i times"
done
tail -f /var/log/syslog
edit /etc/rsyslog.d/50-default.conf
at the bottom add:
if $programname == 'run.sh' then /var/log/run.sh.log
& stop
sudo service rsyslog restart
edit /etc/logrotate.d/rsyslog
at the bottom add:
/var/log/run.sh.log