All txt files in the current directory
# find ./ -name '*.log'
# find ./ -type f -name '*.log'
Files accessed in the last 20 minutes & before 25 minutes & in 28 minutes
# find ./ -name '*.log' -amin -20 ls
# find ./ -name '*.log' -amin +25 ls
# find ./ -name '*.log' -amin 28 ls
Files accessed in the last 2 day
# find ./ -name ‘*.txt’ -atime -1 -ls
Files modified in the last 30 minutes
# find ./ -name ‘*.txt’ -mmin -30 -ls
Files modified in the last 3 day
# find ./ -name ‘*.txt’ -mtime -3 -ls
Files whose status changed in the last 40 minutes
# find ./ -name ‘*.txt’ -cmin -40 -ls
Files whose status has changed in the last 4 days
# find ./ -name ‘*.txt’ -ctime -4 -ls
Deletel selected files
# find ./ -name '*.txt' -amin -20 -ls -exec rm {} \;
# find . -ctime +40 -type f | xargs rm -rf
Crontab
# vim ./clear.sh
#!/bin/sh
find /opt/bak -mtime +6 -name "*.log" -exec rm {} \;
find /opt/bak -mtime +6 -name "*.dmp" -exec rm {} \;
# chmod +x ./clear.sh
# vim /etc/crontab
00 2 * * * root /opt/sh/clear.sh
# systemctl restart crond