Finding recently Modified/Created files in root file system
Posted: 07 Dec 2021, 19:21
Hi Team,
Does anyone have a better version of recent file changes script.
Currently, I am using the below script and assume it missed some files.
Thanks in advance.
#!/bin/bash
#find /`path of folder`/ -iname "*" -mmin -5 -size +100M
# -mmin - minutes, -mtime - days
#"+" changes happened more than 5 minutes ago
#"-" changes happened less than 5 minutes
# -size +100M - shows file size more than 100 Mb
#find /mnt/live/memory/changes -iname "*" -mmin -5 (5 minutes)
#find /mnt/live/memory/changes -iname "*" -mmin -5 -o -iname "*" -cmin -5 --- (I assume this command will find modified and created files)
DIR="$(cd "$(dirname "$0")" && pwd)"
if [ `whoami` != "root" ]; then
echo "Enter sudo pass"
sudo su - -c "$DIR/Find-Changed-Files.sh"
exit
fi
echo
echo -e "Please enter time in Minutes to see Changes happened till that Time" | fmt -w 80
echo
read -e min
echo "Running find /mnt/live/memory/changes - Modified and Created, Sorted in Modification time"
time find /mnt/live/memory/changes -iname "*" -mmin -$min -printf '%Td-%Tm-%TY %.8TT %p\n' -o -iname "*" -cmin -$min -printf '%Td-%Tm-%TY %.8TT %p\n' | sort -n
echo
Find-Changed-Files.sh
Does anyone have a better version of recent file changes script.
Currently, I am using the below script and assume it missed some files.
Thanks in advance.
#!/bin/bash
#find /`path of folder`/ -iname "*" -mmin -5 -size +100M
# -mmin - minutes, -mtime - days
#"+" changes happened more than 5 minutes ago
#"-" changes happened less than 5 minutes
# -size +100M - shows file size more than 100 Mb
#find /mnt/live/memory/changes -iname "*" -mmin -5 (5 minutes)
#find /mnt/live/memory/changes -iname "*" -mmin -5 -o -iname "*" -cmin -5 --- (I assume this command will find modified and created files)
DIR="$(cd "$(dirname "$0")" && pwd)"
if [ `whoami` != "root" ]; then
echo "Enter sudo pass"
sudo su - -c "$DIR/Find-Changed-Files.sh"
exit
fi
echo
echo -e "Please enter time in Minutes to see Changes happened till that Time" | fmt -w 80
echo
read -e min
echo "Running find /mnt/live/memory/changes - Modified and Created, Sorted in Modification time"
time find /mnt/live/memory/changes -iname "*" -mmin -$min -printf '%Td-%Tm-%TY %.8TT %p\n' -o -iname "*" -cmin -$min -printf '%Td-%Tm-%TY %.8TT %p\n' | sort -n
echo
Find-Changed-Files.sh