SA-MP Forums Archive
log rotation - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: log rotation (/showthread.php?tid=386582)



log rotation - ombre - 20.10.2012

Hello,

I saw it https://sampforum.blast.hk/showthread.php?tid=51051 for linux server and the gameserver run but where to put logrotate.sh ?

Thanks


Re: log rotation - Memoryz - 20.10.2012

In the same folder as your samp03svr file.


Re : log rotation - ombre - 21.10.2012

Ok I need just to move on the directory with samp03svr? because there are this phrase "And add entry into Crontab to automate it."


Re : log rotation - ombre - 21.10.2012

up please


Re: log rotation - Programie - 30.04.2013

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.