sdruss
asked on
Control Number of Log Files -Perl
I have an application written in Perl, that generates huge number of files. Need a Perl snippet to limit the number of log files written to our "/var/tmp" directory. Yesterday we accumulated 7,500 files, and rumor is this may/could slow down the whole environment.
Are you able to locate the part that handles the log file creation?
Is this perl program open source that one can refer to?
Is this perl program open source that one can refer to?
ASKER
Kim Ryan - interested in keeping file around 7 days. Suspect this can be accomplished with call to: stat($file)? Thanks!
ASKER
Arnold - no this is not an open source Perl thing.
Understanding how (mechanism) the logs are generated, see whether the application has builtin log control size if file before a new One is started.
Run fuser on the current log file. Note the pid, run ps -ef | grep <pid>
To see whether there is a different process that actually handles the log file write-outs......
depending on the frequency of which you will be running the log deletion versus the current log creation rate
a simple
ls -lt /var/tmp | grep 'filename of interest' | tail -3 |xargs -i rm ....
This way when this runs out of cron, the oldest three files will be deleted.....
Run fuser on the current log file. Note the pid, run ps -ef | grep <pid>
To see whether there is a different process that actually handles the log file write-outs......
depending on the frequency of which you will be running the log deletion versus the current log creation rate
a simple
ls -lt /var/tmp | grep 'filename of interest' | tail -3 |xargs -i rm ....
This way when this runs out of cron, the oldest three files will be deleted.....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Very nice. Absolutely good to go.
l
Open in new window