Special January 2019 - Simple logfile rotation
|
Category : Admin
|
Level : Easy
|
|
Back to Overview
|
During database operation the written logfile ( cego.log ) is written in a continious way and as a result the file is subsequently growing.
So it might we useful to save written log data to an archive file, which can be archived or removed if not needed any more.
This can be done using a small shell script savelog as show below
#!/bin/bash
TS=`date +%d%m%Y`
cp cego.log cego-$TS.log
cat /dev/null > cego.log
|
To invoke the script in a synchronized way, it can be used with the admin sync command
CGADM > sync tableset TS1 with './savelog' timeout 3;
Tableset TS1 in sync with escape command
ok ( 0.138 s )
|
This results in a archived logfile and the current still active logfile
bigmac.local> ls -l cego*.log
-rw-r--r-- 1 lemke staff 10876 Jan 13 13:44 cego-13012019.log
-rw-r--r-- 1 lemke staff 355 Jan 13 13:44 cego.log
|