Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Deleting old messages of users who haven't logged in for a long time

  1. #1
    Join Date
    Aug 2011
    Posts
    23
    Rep Power
    4

    Default Deleting old messages of users who haven't logged in for a long time

    Hi,

    We have more then 9000 students and no longer want to keep old messages of them. Too much disk space.

    Is there a simple method to run a script (say) every month and delete all the messages which are
    - older then (say) 3 months of users of a specific domain,
    - and also haven't logged in for the last (say) 3 months.

    Regards.

  2. #2
    Join Date
    Jan 2012
    Posts
    41
    Rep Power
    3

    Default

    You can use this command to search for accounts.

    Code:
    zmprov sa "zimbraLastLogonTimestamp<=$(date --date='3 months ago' +%Y%m%d%H%M%SZ)"
    You can use this command to find messages older than 3 months old for any account

    Code:
    zmmailbox -z -m account@domain.com s "before:$(date --date="3 months ago" +%m\/%d\/%Y)"
    And then you can delete the results

  3. #3
    Join Date
    Aug 2011
    Posts
    23
    Rep Power
    4

    Default

    Interestingly, I receive the error message below.

    I have tested the commands while another shell was actively monitoring htop, and the memory util never reaches 50%.

    We have a couple of domain names and over 9500 accounts. Can this be a bug or just because of the number of accounts ? Any workaround ?

    What we have is "8.0.2_GA" running on Ubuntu 12.04LTS server.

    Error Message:
    zimbra@servername:~$ zmprov sa "zimbraLastLogonTimestamp<=$(date --date='3 months ago' +%Y%m%d%H%M%SZ)"
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2367)
    at java.lang.AbstractStringBuilder.expandCapacity(Abs tractStringBuilder.java:130)
    at java.lang.AbstractStringBuilder.ensureCapacityInte rnal(AbstractStringBuilder.java:114)
    at java.lang.AbstractStringBuilder.append(AbstractStr ingBuilder.java:535)
    at java.lang.StringBuilder.append(StringBuilder.java: 204)
    at com.zimbra.common.util.ByteUtil.getContent(ByteUti l.java:230)
    at com.zimbra.common.soap.SoapHttpTransport.invoke(So apHttpTransport.java:254)
    at com.zimbra.common.soap.SoapHttpTransport.invoke(So apHttpTransport.java:167)
    at com.zimbra.common.soap.SoapTransport.invoke(SoapTr ansport.java:386)
    at com.zimbra.common.soap.SoapTransport.invokeWithout Session(SoapTransport.java:372)
    at com.zimbra.cs.account.soap.SoapProvisioning.invoke Request(SoapProvisioning.java:442)
    at com.zimbra.cs.account.soap.SoapProvisioning.invoke (SoapProvisioning.java:450)
    at com.zimbra.cs.account.soap.SoapProvisioning.invoke Jaxb(SoapProvisioning.java:500)
    at com.zimbra.cs.account.soap.SoapProvisioning.search Directory(SoapProvisioning.java:1806)
    at com.zimbra.cs.account.ProvUtil.doSearchAccounts(Pr ovUtil.java:1980)
    at com.zimbra.cs.account.ProvUtil.execute(ProvUtil.ja va:1107)
    at com.zimbra.cs.account.ProvUtil.main(ProvUtil.java: 3513)

  4. #4
    Join Date
    Jan 2012
    Posts
    41
    Rep Power
    3

    Default

    Out of memory... You can try it per domain, like this:

    Code:
    zmprov sa "zimbraLastLogonTimestamp<=$(date --date='3 months ago' +%Y%m%d%H%M%SZ)" domain mail1.example.com

  5. #5
    Join Date
    Jan 2012
    Posts
    41
    Rep Power
    3

    Default

    You can use ldap for your query:

    Find your variables here:

    Code:
    zmlocalconfig -s | grep 'ldap_' | egrep 'password|url'
    and use them here:

    Code:
    ldapsearch x -H ldap_master_url -D "cn=config" -w zimbra_ldap_password "zimbraLastLogonTimestamp<=$(date --date='3 months ago' +%Y%m%d%H%M%SZ)"
    You should use some stream editor like sed or awk to make your search results usable.

  6. #6
    Join Date
    Aug 2011
    Posts
    23
    Rep Power
    4

    Default

    Hi stasouv,

    "zmprov ..... domain....." works great with domains having a a few hundred accounts, but results with the same error when used for the domain having 8000 accounts.

    The "ldapsearch ..." command however, results with the whole list of accounts, regardless of their LastLogonTimeStamp, although the result starts with the lines below ;
    # extended LDIF
    #
    # LDAPv3
    # base <> (default) with scope subtree
    # filter: (objectclass=*)
    # requesting: x zimbraLastLogonTimestamp<=20130720001800Z
    #
    Last edited by mscag; 04-19-2014 at 02:52 PM.

  7. #7
    Join Date
    Jan 2012
    Posts
    41
    Rep Power
    3

    Default

    Sorry, wrong copy/paste...

    Instead of "x", it should be "-LLLx". Plus, I forgot to add the "mail zimbraLastLogonTimestamp" at the end of the line, in order to return only those fields... Once you check it works you can remove "zimbraLastLogonTimestamp" at the end of the line and grep with "@" to have the list of addresses.

    Code:
    ldapsearch -LLLx -H ldap_master_url -D "cn=config" -w zimbra_ldap_password "zimbraLastLogonTimestamp<=$(date --date='3 months ago' +%Y%m%d%H%M%SZ)" mail zimbraLastLogonTimestamp | grep "^mail" | cut -d " " -f2

  8. #8
    Join Date
    Aug 2011
    Posts
    23
    Rep Power
    4

    Default

    Thanks for the correction.

    the command already produces the list of the email addresses in the format "username@domain.com". So I didn't get what you meant by "remove "zimbraLastLogonTimestamp" at the end....."

    Anyway, three more steps for the target ;

    1 - The command "zmmailbox -z -m account@domain.com s "before:$(date --date="3 months ago" +%m\/%d\/%Y)"" produces a list of messages like below, but only for the latest 25 messages. How do I get the whole list of them ?

    No Id Type From Subject Date
    ----- ---- ----- --------------- -------------------------------------------------- --------------
    1. -1940 conv sender1 Subject1 - lsdk flks jskd jaljfadslk dslkjkdfalfk 01/17/14 16:51
    2. -1921 conv sender1 Quota warning 01/17/14 16:34
    3. -1920 conv sender2 Subject2 - lsdk flks jskd jaljfadslk dslkjkdfalfk 01/17/14 16:34
    4. -1904 conv sender1 menu 01/11/14 12:49
    (sorry, I can't build a tabular format )

    2 - The result does not include the "Never Logged In" accounts. How do I get this ?

    3 - How do I delete these messages ? (Hint: there are some same ID's when old messages are listed for different accounts.)
    Last edited by mscag; 04-20-2014 at 12:01 AM.

  9. #9
    Join Date
    Jan 2012
    Posts
    41
    Rep Power
    3

    Default

    You can get up to 1000 messages by adding "l 1000" after "s" (s l 1000). After that you need to iterate.

    Then you will get a list of messages. Entries starting with a hyphen (like -1940) refer to messages. Entries starting with no hyphen (eg 1950) refer to conversations.

    To delete messages:

    zmmailbox -z -m account@domain.com dm m1,m2,m3.. (without the hyphens)

    To delete conversations:

    zmmailbox -z -m account@domain.com dc c1,c2,c3....

  10. #10
    Join Date
    Aug 2011
    Posts
    23
    Rep Power
    4

    Default

    Thanks Stasouv,

    and how can I obtain the list of "never logged in" users for a specific domain ?

Similar Threads

  1. Session Time Out Policy - logged out active users
    By emnzava in forum Administrators
    Replies: 3
    Last Post: 10-13-2013, 05:09 AM
  2. Replies: 1
    Last Post: 03-08-2010, 06:55 PM
  3. after upgrade some users haven't hotkeys
    By lukefilewalker in forum Administrators
    Replies: 1
    Last Post: 02-09-2010, 07:12 PM
  4. Logged on users
    By vince in forum Zimbra in Education
    Replies: 3
    Last Post: 01-14-2008, 11:35 AM
  5. Replies: 0
    Last Post: 07-20-2007, 08:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •