Any ideas how can I display log files that older than (i.e. 10 days). Note that these logs were not accessed, changed or modified … Thanks
find /logfiledir -mtime +10 -exec ls -l {} ;
cd /dir
find . -name “*” -exec ls -l {} ;
find . -name “*” -exec rm {} ; ]
Find and delete all files 30 days and older:
find /tmp/* -atime +30 -exec rm {} ;
replace /tmp for anything you want.
replace rm for any command you like .
cd /dir
find . -name “*” -exec ls -l {} ;
find . -name “*” -exec rm {} ;
#!/usr/bin/sh
#to locate files in a file system
#ensure that /tmp/locate.db file exists and is updated regularly
db=”/tmp/locate.db”
if [ $# -lt 1 ]
then
echo “Usage: $0 filename[s]. ”
exit 1
fi
if [ ! -f $db ]
then
echo “$db doesn’t exist. ”
echo “Execute the following command to create it. For regular updations, setup a cron job.”
echo “find / -print $db”
exit 1
fi
for i in $*
do
grep -i $i /tmp/locate.db
done