trunk/3rdparty/srs-docs/doc/log-rotate.md
SRS always writes log to a single log file srs.log, so it will become very larger. We can use rotate the log to zip or remove it.
mv objs/srs.log /tmp/srs.`date +%s`.logkillall -s SIGUSR1Recommend to use logrotate to manage log files.
sudo yum install -y logrotate
cat << END > /etc/logrotate.d/srs
/usr/local/srs/objs/srs.log {
daily
dateext
compress
rotate 7
size 1024M
sharedscripts
postrotate
kill -USR1 \`cat /usr/local/srs/objs/srs.pid\`
endscript
}
END
Note: Run logrotate manually by
logrotate -f /etc/logrotate.d/srs
For SRS2, we could use copytruncate, but it's strongly not recommended because the logs maybe dropped, so it's only a workaround for server not supported SIGUSR1 such as SRS2.
Yes, SRS3 surely supports copytruncate and it's not recommended.
The config is bellow, from PR#1561 by wnpllrzodiac:
cat << END > /etc/logrotate.d/srs
/usr/local/srs/objs/srs.log {
daily
dateext
compress
rotate 7
size 1024M
copytruncate
}
END
Winlin 2016.12