Yeah I know "You should not post in an old thread" but I want to share my knowledge with the rest of the world and don't want to create a new thread for the same topic.
I want to do the same thing. I just realized that if you are running the SA-MP server for a long time, the log is getting really big. So I thought about log rotation.
Yes, you can use a simple shell script which copies the server_log.txt to another file (Maybe timestamped or numbered) and truncate the original server_log.txt to 0 bytes. But hey, there is already something available in most Linux distributions: It's called
logrotate.
I've created a file "samp-server" in /etc/logrotate.d with the following content:
Код:
/path/to/samp/*_log.txt
{
daily
missingok
copytruncate
rotate 7
compress
delaycompress
notifempty
}
The
*_log.txt will match every file ending with
_log.txt (e.g.
server_log.txt or
mysql_log.txt).
This logrotate configuration will rotate the logs of the SA-MP server every day and keeps up to 7 log files.
And the best: Older logs are automatically gzipped!
See more details in the
man page of logrotate.