Need help with small shell script

tecwithquestion

Well-Known Member
Oct 20, 2014
61
1
58
cPanel Access Level
Root Administrator
Hello

I am using below script to monitor spam on server ::

Code:
#!/bin/bash
EMAIL="[email protected]
NOW=$(date +"%m-%d-%Y")
FILE="cwd.$NOW.txt"
grep "cwd=/home" /var/log/exim_mainlog | awk '{for(i=1;i<=10;i++){print $i}}' | sort | uniq -c | grep cwd | sort -n > /usr/local/cwd/$FILE
echo "Mail queue at `hostname` has $MQUEUE messages!!!" | mail -s "CRITICAL ALERT: Mail queue" -a /usr/local/cwd/$FILE  $EMAIL
fi
Out put of this script is like ::

Code:
  4 cwd=/home/xxx/public_htmlme/xxxx/public_html/xxxx/xxxx/xxx/xxx
  10 cwd=/home/xxxx/public_html/xxxx
  14 cwd=/home/xxxx/public_html
  30 cwd=/home/xxxx/public_html/xxxxt/wp-content/plugins/pie-register/classes
  61 cwd=/home/xxxx/public_html
  765 cwd=/home/xxxx/public_html/xxxx/media/kunena/avatars/resized/size200
I want to have ::

script will set permission to 0000 for a folder from which more than 500 emails sent out..

Any help regarding this is highly appreciated.
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463