shell script to check newly created files in a directory and its sub directories

Shell script to check newly created files in a directory and its sub directories
The below shell script is to monitor a Directory and its sub-directories, and log the information when particular type of files are created/found.

The below script will monitor a directory "/opt/krish" for .sh files.
If there exists any .sh files in the directory (includes sub-directories) it will log the information in the results.log file in the same directory.
It repeats this operation for every 10 seconds so that any newly created file information will be captured.

You can keep on creating some test files using "touch d11.sh" in the same directory to verify whether the same is been logged in the results.log or not.

nc184120:/opt/krish # cat check.sh
#!/bin/ksh
cd /opt/krish
> results.log
date >> results.log
while true
do
    for file in `find . -type f -name "*.sh"`
    do
          ls -lrt $file >> results.log

    done
    sleep 0
done


0 comments to "shell script to check newly created files in a directory and its sub directories"

Post a comment

Whoever writes Inappropriate/Vulgar comments to context, generally want to be anonymous …So I hope U r not the one like that?
For lazy logs, u can at least use Name/URL option which doesn’t even require any sign-in, The good thing is that it can accept your lovely nick name also and the URL is not mandatory too.
Thanks for your patience
~Krishna(I love "Transparency")

Popular Posts

Enter your email address:

Buffs ...

Tags


Powered by WidgetsForFree