Mini Shell
#!/bin/bash
#clean up lastrun files that shouldn't exist
for user in $(/usr/bin/find /var/cpanel/lastrun/ -type f -mmin +2160 | cut -d/ -f5 | sort -u); do
if ! id "$user" &>/dev/null ; then # if system user does not exist
rm -f "/var/cpanel/users/$user"
if [ ! -f "/var/cpanel/users/$user" ]; then
rm -rf "/var/cpanel/lastrun/$user"
fi
fi
done
/usr/bin/find /var/cpanel/lastrun/ -type f -mmin +2160 | wc -l > /home/nagios/oldlogcount
chown nagios.nagios /home/nagios/oldlogcount
Zerion Mini Shell 1.0