Logo Background

Log File Housekeeping Jobs

  • By on November 4, 2009 | No Comments

    Looking for better ways to perform log file housekeeping in your daily, weekly or monthly jobs as Unix or system administrator? Usually we will use the find command as below to search for any files that was larger than 100Mb before proceed to the housekeeping.

    Useful Housekeeping Script

    $ find . -size +100000000c -exec ls -l {} \;

    All the output file listed from this command means that it was larger that 100Mb. You can change it to find file larger that 1GB by adding another “0” in the command above.

    Use the script as below to zip all the log file into a single backup file. Notice that I use the tar command follow by the gzip command to achieve the housekeeping jobs. Tar command depending on your Unix variant you are working at has the additional parameter to perform compression too.

    $ cd <to directory name you want to backup>
     
    $ tar -cvf /backup/log_file_housekeeping_jobs.tar *.*
     
    $ cd /backup
     
    $ gzip log_file_housekeeping_jobs.tar

    But for our case in HP-UX, we don’t have the privileges to have compression parameter in tar command thus we execute another gzip command independently.

    The final backup output you should see will be log_file_housekeeping_jobs.tar.gz.

    Previous
    Next
    » TAR Extract File To Given Directory
Leave a Comment