Hi,

I am not a much of a script writer but I would appreciate someone's help with writing a short script which after you give it a parameter would disable old users on the Zimbra server, for example: ./disable-accounts.sh 90 - would disable all accounts not logged for over 90 days, excluding never logged-in accounts. Can anyone help, please?

I have found the following script in one old post which could be modified for the purpose:

Code:
domain="@example.com"
ACCT=/tmp/acct.txt
OUTPUT=/tmp/user.list

rm -rf $ACCT $OUTPUT

zmaccts | grep $domain | sed /wiki/d | sed /admin/d | sed /spam./d | sed /ham./d
 > $ACCT

today=`date '+%s'`
userinput=`echo "$1*24*60*60" | bc`

cat $ACCT |
while read line; do
   name=`echo $line | awk '{print $1}'`
   if [ `echo $line | awk '{print $5}'` = "never" ]; then 
      echo "$name never" >> $OUTPUT
          continue
   else
      lastlogin=`echo $line | awk '{print $5}' | awk -F/ '{print 2000+$3 $1 $2}'
`
   fi

  last=`date -d $lastlogin '+%s'`
  if [ `echo "$today - $last" | bc` -ge $userinput ]; then
     echo "$name $lastlogin" >> $OUTPUT
  fi

done
Many thanks!