I need to write a script to copy log files.
There are two format of logs:
System_<date_timestamp>.log
trace_<date_timestamp>.log
New files are generated when trace log reaches 20 MB and sytem log reaches 10MB.
Only 5 of these logs (5 for each kind) are allowed to be saved, once there is more than 5 of them, the old files get deleted and replaced by new ones.
Therefore, before they get deleted I need to copy them to a different location so that I can view them later when needed to debug.
Basically, it will look like the following (showing just trace log format, similar with System log):
trace_12.03.05_17.11.20.log
trace_12.03.05_17.12.30.log
trace_12.03.05_17.13.45.log
trace_12.03.05_17.13.23.log
trace_12.03.05_17.14.40.log
Best Answer
Also you can use log-rotate for the same, see following example
save above file, let say
/etc/logrotate_trace.conf
then simply set cron job for every hourfor testing you can run it from command line as