Skip to main content

Archive logs older than 10 days

This shell command would archive log files that modification times are older than ten days. Find command takes arguments like -maxdepth 1 for maximum level of directories to dig , -type -f for identifying files, -name '*.log' for filtering log files, -mtime +10 for filtering modification time and -exec mv for executing commands for every file that found.

find /ftp/logs/ -maxdepth 1 -type f -name '*.log' -mtime +10 -exec mv {} /ftp/logs/archive/ \;

Comments

Popular posts from this blog