{"id":302,"date":"2015-05-12T23:33:43","date_gmt":"2015-05-12T15:33:43","guid":{"rendered":"http:\/\/www.scriptsmy.com\/?p=302"},"modified":"2023-04-28T09:47:13","modified_gmt":"2023-04-28T09:47:13","slug":"how-to-show-mailbox-size-on-zimbra-via-bash-script","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-show-mailbox-size-on-zimbra-via-bash-script\/","title":{"rendered":"How to Show Mailbox Size on Zimbra via Bash Script"},"content":{"rendered":"<p><strong>Q.<\/strong> How to show mailbox Size on Zimbra via bash script ?<\/p>\n<p><strong>A. <\/strong>There are two script available to show mailbox size of the zimbra users :<\/p>\n<h4>Option A<\/h4>\n<h5>1. Create the scripts directory to keep the bash file and give zimbra ownership to the folder :<\/h5>\n<pre># mkdir -p \/opt\/zimbra\/backup\/scripts\n# chown -R zimbra:zimbra \/opt\/zimbra\/backup\/scripts\n<\/pre>\n<h5>2. Create bash script as below :<\/h5>\n<pre># vi \/opt\/zimbra\/backup\/scripts\/mailboxsize1.sh\n<\/pre>\n<p>Add the following :<\/p>\n<pre>#!\/bin\/bash\nall_account=`zmprov -l gaa`;\nfor account in ${all_account}\ndo\n    mb_size=`zmmailbox -z -m ${account} gms`;\n    echo \"Mailbox size of ${account} = ${mb_size}\";\ndone\n<\/pre>\n<h5>3. Give ownership to zimbra group and user and make the script executable :<\/h5>\n<pre># chown -R zimbra:zimbra \/opt\/zimbra\/backup\/scripts\/mailboxsize1.sh\n# chmod +x \/opt\/zimbra\/backup\/scripts\/mailboxsize1.sh\n<\/pre>\n<h5>4. As a zimbra user run the following script :<\/h5>\n<pre># su - zimbra\n<\/pre>\n<pre>$ \/opt\/zimbra\/backup\/scripts\/mailboxsize1.sh\n<\/pre>\n<p>Sample output :<\/p>\n<pre>Mailbox size of admin@ehowstuff.local = 217.23 KB\nMailbox size of spam.wc5ohhoylp@ehowstuff.local = 0 B\nMailbox size of ham.ypxiyleoyj@ehowstuff.local = 0 B\nMailbox size of virus-quarantine.kl6ejsnmd@ehowstuff.local = 0 B\nMailbox size of galsync.vtfk6uwt@ehowstuff.local = 0 B\nMailbox size of user1@ehowstuff.local = 375.28 KB\nMailbox size of user2@ehowstuff.local = 24.97 KB\n<\/pre>\n<h4><\/h4>\n<h4>Option B<\/h4>\n<h5>1. Create the scripts directory to keep the bash file and give zimbra ownership to the folder :<\/h5>\n<pre># mkdir -p \/opt\/zimbra\/backup\/scripts\n# chown -R zimbra:zimbra \/opt\/zimbra\/backup\/scripts\n<\/pre>\n<h5>2. Create bash script as below :<\/h5>\n<pre># vi \/opt\/zimbra\/backup\/scripts\/mailboxsize2.sh\n<\/pre>\n<p>Add the following :<\/p>\n<pre>#!\/bin\/bash\noutput=\"\/tmp\/accountusage\"\ndomain=\"ehowstuff.local\"\n\nrm -f $output\ntouch $output\n\nserver=`zmhostname`\n\/opt\/zimbra\/bin\/zmprov gqu $server|grep $domain|awk {'print $1\" \"$3\" \"$2'}|sort|while read line\ndo\nusage=`echo $line|cut -f2 -d \" \"`\nquota=`echo $line|cut -f3 -d \" \"`\nuser=`echo $line|cut -f1 -d \" \"`\nstatus=`\/opt\/zimbra\/bin\/zmprov ga $user | grep  ^zimbraAccountStatus | cut -f2 -d \" \"`\necho \"$user `expr $usage \/ 1024 \/ 1024`Mb `expr $quota \/ 1024 \/ 1024`Mb ($status account)\" &gt;&gt; $output\ndone\n\ncat $output\n<\/pre>\n<h5>3. Give ownership to zimbra group and user and make the script executable :<\/h5>\n<pre># chown -R zimbra:zimbra \/opt\/zimbra\/backup\/scripts\/mailboxsize2.sh\n# chmod +x \/opt\/zimbra\/backup\/scripts\/mailboxsize2.sh\n<\/pre>\n<h5>4. As a zimbra user run the following script :<\/h5>\n<pre># su - zimbra\n<\/pre>\n<pre>$ \/opt\/zimbra\/backup\/scripts\/mailboxsize2.sh\n<\/pre>\n<p>Sample output im MB:<\/p>\n<pre>admin@ehowstuff.local 0Mb 0Mb (active account)\ngalsync.vtfk6uwt@ehowstuff.local 0Mb 0Mb (active account)\nham.ypxiyleoyj@ehowstuff.local 0Mb 0Mb (active account)\nspam.wc5ohhoylp@ehowstuff.local 0Mb 0Mb (active account)\nuser1@ehowstuff.local 0Mb 0Mb (active account)\nuser2@ehowstuff.local 0Mb 0Mb (active account)\nvirus-quarantine.kl6ejsnmd@ehowstuff.local 0Mb 0Mb (active account)\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Q. How to show mailbox Size on Zimbra via bash script ? A. There are two script available to show mailbox size of the zimbra users : Option A 1&#8230;.<\/p>\n","protected":false},"author":6,"featured_media":6320,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1100],"tags":[1536,1739,1946,1951],"class_list":["post-302","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-zimbra","tag-linux","tag-scripts","tag-zimbra","tag-zimbra-collaboration-suite"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=302"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/302\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/6320"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}