Pages

Bash Script: List Last Modified Files on Linux Server

Today I am going to share a simple bash shell script to list the last modified files in a linux server directory. If I Google search this topic then I get several articles / blog posts suggesting to install some tools and then use that tool to find the information but I don't want to install anything on my server so I just went ahead and created one bash shell script that uses find command and placed it in my cronjob that notifies me via email if the content of the file(s) is changed or a new file is created in the directory.

I encourage you to please download the script lastModifiedFiles.sh from GitHub and give it try and don't hesitate to make a comment on this post if you have any issue or some suggestions to improve the script.

You can check the script here:

https://github.com/sumitgoel17/sysAdminScripts/blob/master/lastModifiedFiles.sh

Usage: lastModifiedFiles.sh <directory path>

Make sure to update the correct notification email address in the script and if you want to run this script from cronjob then you have an option to hard code the directory path in the script. If you have defined the path in command line and also have hard coded path then command line argument will be used. Also, remember the lookup time in the script while setting up the cronjob for accurate information.

Any feedback will be highly appreciated.

Suggested Posts,

This post appeared on the softlexicon.com by Sumit Goel. Copyright © 2012–2013 – softlexicon.com and Sumit Goel. All rights reserved. Not to be reproduced for commercial purposes without written permission.

1 comment:

Be sure to check back again because I do make every effort to reply to your comments here.