Lyrics - Remove old files, Check if file is in use before deleting
Remove old files
Remove files older than 10 days
# find /tmp/tmpfiles* -mtime +10 -exec rm {} \;
Remove files starting with tmp[a to g]
# find /tmp/tmp[a-g]* -mtime +10 -exec rm {} \;
Check files being used or not by using fuser
#!/bin/bash
for i in `ls -p /tmp/ | grep -v /`
do
fuser $i
exitstate=$?
if [$exitstate -eq 0 ]
then
echo "$i the file is in use"
else
echo "$i is deleted"
rm $i
done
Count inodes in a directory
# ll -R | wc -l
# find /tmp -xdev -printf '%h/n' | sort | uniq -c | sort -k -1 -n | tail -10
# { find /tmp -xdev -printf '%h/n' | sort | uniq -c | sort -k -1 -n ; } 2 > /dev/null
The topic on Lyrics - Remove old files is posted by - Indhrani
Hope you have enjoyed, Lyrics - Remove old filesThanks for your time