Created
September 25, 2015 16:24
-
-
Save rushipkar90/cce738e98efc33b6e82c to your computer and use it in GitHub Desktop.
auto_terminate.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Directory to store log files in | |
DST=/root/autotermination_logs | |
# Create DST if it doesn't exist | |
if [ ! -d "$DST" ]; then | |
mkdir -p $DST | |
fi | |
date_diff() { | |
echo $(((`date -d $1 +%s`-`date +%s`)/(24*3600))); | |
} | |
for s_lst in `ls -A /var/cpanel/suspended` | |
do | |
if [ `du -b /var/cpanel/suspended/$s_lst | awk '{print $1}'` -eq 0 ] && [ `date_diff \`date +%Y-%m-%d -r /var/cpanel/suspended/$s_lst\`` -le -30 ]; | |
then | |
echo -e "\n\n\nTerminating $s_lst on at `date +%r`" >> $DST/terminated-`date +%F`.txt | |
echo 'y' | /scripts/killacct --killdns $s_lst >> $DST/terminated-`date +%F`.txt | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment