linux - Logrotate every 30th second and store logfiles in date-named directories -


i've got centos installation busy webserver. need aquire stats log files , keep old ones, ordered date.

every 30th second, current logfile should closed , processed (analysing entries , storing them database). since generates lot of logfiles, want group them directories, named date.

at moment, have 2 files; rotation.conf , rotatenow.sh. shell-file creates directories, based on ymdhms. after that, run command "logrotate ./rotation.conf -v --force" in order invoke proces, how make config-file put log newly generated directory? can whole thing done inside config-file?

now="$(date)" now="$(date +'%y-%m-%d-%h:%m:%s')" foldernavn="/var/www/html/stats/logs/nmdstats/closed/$now" mkdir $foldernavn logrotate ./nmdhosting.conf -v --force 

at moment, config-file looks this:

/var/www/html/stats/logs/nmdhosting/access_log {     ifempty     missingok     (i stuck)     (do post-processing - run perl-script) } 

any ideas appreciated.

update: tried different approach, adding httpd.conf:

transferlog "|usr/sbin/rotatelogs /var/www/html/stats/logs/nmdstats/closed/activity_log.%y%m%d%h%m%s 30". 

it works, apparently, can't run pre/post processing script when using method. essential in order update database. perhaps run shell/perl-script using cronjob, don't trust method. search goes on...

update 2: i've tested cronolog - project - required functionalities haven't been implemented yet, on to-do. since latest version 2002, i'm not going wait around happen :)

however, unaware of inotify-tools, managed set listener:

srcdir="/var/www/html/stats/logs/nmdstats/history/" inotifywait -m -e create $srcdir | while read filename eventlist eventfile     echo "this logfile has been closed: $eventfile" done 

i think, can handle here. thank you, john

no need cron: if use transerlog httpd.conf option create new log file every 30 seconds, can run post-processing daemon watches output directory inotifywait (or python's pyinotify, etc.). see here: inotify , bash - let notified os after new file created etc.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -