This is the basic task in application support that requires log files to remove, back up to other location that are older than "N" days or let suppose 7 days from system date.
Sometimes requirement may ask you to run this task automatically on specified day, date and time to check on system file system, then you may use below commands in cron schedule on UNIX by making a script and set with schedule on crontab.
- find the log files that are older than "n" days and remove all ? write the command plz....
$ find <path-to-check> -name *.log -mtime +n -exec rm -rf {}\;
Here <path-to-check> is server location or path to check and "+n" shows days. * is wild card to check all log files having extension .log
Example :
$ find /tmp/logs -name *.log -mtime +7 -exec rm -rf {}\;
Above will remove all log files older than 7 days.
No comments:
Post a Comment