| Server IP : 104.129.129.72 / Your IP : 216.73.216.229 Web Server : LiteSpeed System : Linux 123answers 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64 User : answe8064 ( 1002) PHP Version : 8.2.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /etc/cron.daily/ |
Upload File : |
#!/bin/bash
availablespace="$(df / | awk 'NR==2{print $4}')"
if [ "$availablespace" -gt "1000000" ]; then
exit 0
fi
# Generate list of large files in log directories
largeFilesList="$(find /var/log/ -type f -size +10000k | sort | xargs -r file)"
if [ -z "$largeFilesList" ]; then
exit 0
fi
# Find text files and empty them
textFiles="$(printf "$largeFilesList" | tr ':' ' ' | grep -i text)"
printf "$textFiles" | awk '{ print "emptying "$1 }'
printf "$textFiles" | awk '{ print $1 }' | xargs -r truncate --size 0
# Find gzipped log files and remove them
gzipFiles="$(printf "$largeFilesList" | tr ':' ' ' | grep -i gzip)"
printf "$gzipFiles" | awk '{ print "deleting "$1 }'
printf "$gzipFiles" | awk '{ print $1 }' | xargs -r rm -f
exit 0