Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-23-2011, 05:03 AM
Elite Member
 
Posts: 305
Default Creating reports with CRON

There have been times, when we've removed accounts that have been the only subscribers to a distribution list.

When this happens, it's left the distribution list with zero subscribers. I've written a script that will go though all of our lists, count the number of subscribers and email that to the admins.

The script works fine when running it manually, but when running it from CRON, it will only go though the loop, maybe 3 or 4 times, before terminating.

The CRON job entry is running as root, under Ubuntu 8.04LTS 64bit:

Code:
30 21 * * * /usr/local/bin/list_report.sh 2>&1  # Distribution list summary report


Any suggestions would be welcome, script below:

Code:
#!/bin/bash

##############
# Set up paths
##############

PATH=/opt/zimbra/bin:/opt/zimbra/postfix/sbin:/opt/zimbra/openldap/bin:/opt/zimbra/snmp/bin:/opt/zimbra/bdb/bin:/opt/zimbra/openssl/bin:/opt/zimbra/java/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games                                          
                                                                                                                                            
#####################################                                                                                                       
# Export available distribution lists                                                                                                       
#####################################                                                                                                                                                                                                                                                 
zmprov gadl >/home/doug/reports/lists.tmp                                                                                                   
                                                                                                                                            
###############                                                                                                                             
# Sort the list                                                                                                                             
###############                                                                                                                             

sort /home/doug/reports/lists.tmp >/home/doug/reports/lists.txt

#################################
# Create report and email headers
#################################

    echo "to:support@fakedomain.com" >/home/doug/reports/reports.txt
    echo "from:root@fakedomain.com" >>/home/doug/reports/reports.txt
    echo "subject:Distribution List Summary" >>/home/doug/reports/reports.txt

    echo "Count    List name" >>/home/doug/reports/reports.txt
    echo "------------------" >>/home/doug/reports/reports.txt
    echo "Count    List name"
    echo "------------------"

############################
# Read sorted list of names
# and get a count of members
############################

while read list_name
do

    eval total_lists=`expr $total_lists + 1`
    
    eval list_count=`zmprov gdl "$list_name" |grep -i zimbramailforwardingaddress|wc -l`
    
    echo "  $list_count      $list_name"
    echo "  $list_count      $list_name" >>/home/doug/reports/reports.txt


done </home/doug/reports/lists.txt

#########################################
# Add total number of lists to the report
#########################################

    echo "" >>/home/doug/reports/reports.txt
    echo "" >>/home/doug/reports/reports.txt
    echo "List count: $total_lists" >>/home/doug/reports/reports.txt
    
####################
# Send out the email
####################

/opt/zimbra/postfix/sbin/sendmail -t </home/doug/reports/reports.txt
Thanks,

Doug
__________________
Ben Franklin quote:

"Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety."
Reply With Quote
  #2 (permalink)  
Old 12-07-2011, 10:47 AM
Elite Member
 
Posts: 305
Default

The fix to this was to change from #!/bin/bash to #!/bin/sh

Doug
__________________
Ben Franklin quote:

"Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety."
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.