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