The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help with small shell script

Discussion in 'E-mail Discussions' started by tecwithquestion, Apr 16, 2015.

  1. tecwithquestion

    tecwithquestion Active Member

    Joined:
    Oct 20, 2014
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Hello

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

    Code:
    #!/bin/bash
    EMAIL="user@email.com
    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.
     
    #1 tecwithquestion, Apr 16, 2015
    Last edited: Apr 16, 2015
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,744
    Likes Received:
    662
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page