Find the answer to your Linux question:
Results 1 to 5 of 5
I am running a qmail server for myself and a few family members. I am not running spam assassin in a way that affords each user to create their own ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2006
    Posts
    3

    sa-learn script


    I am running a qmail server for myself and a few family members. I am not running spam assassin in a way that affords each user to create their own spam assassin learning database. What I am currently doing to update the global spam assassin db is running the following script in crontab:
    Code:
    #!/bin/sh
    ## sa-learn User1 and User2's Junk mail and Ham folders
    ##
    sa-learn --showdots --no-sync --spam /home/vpopmail/domains/domain1/user1/Maildir/.Junk/cur/
    
    sa-learn --showdots --no-sync --ham /home/vpopmail/domains/domain1/user1/Maildir/.Ham/cur/
    
    sa-learn --showdots --no-sync --spam /home/vpopmail/domains/domain2/user2/Maildir/.Junk/cur/
    
    sa-learn --showdots --no-sync --ham /home/vpopmail/domains/domain2/user2/Maildir/.Ham/cur/
    
    sa-learn --sync
    rm -f /home/vpopmail/domains/domain1/user1/Maildir/.Junk/cur/*
    rm -f /home/vpopmail/domains/domain1/user1/Maildir/.Ham/cur/*
    rm -f /home/vpopmail/domains/domain2/user2/Maildir/.Junk/cur/*
    rm -f /home/vpopmail/domains/domain2/user2/Maildir/.Ham/cur/*
    chown spamd:spamd /home/spamd/\.*
    sa-learn --dump magic

    What I would like to do to change the functionality of this program to follow the methodology in a way where I would execute the two learn commands (ham & spam) once, using a command line that would be recursive on a wildcard such as this:

    Code:
    sa-learn --showdots --no-sync --spam /home/vpopmail/domains/*/*/Maildir/.Junk/cur/
    and
    Code:
    sa-learn --showdots --no-sync --ham /home/vpopmail/domains/domain1/user1/Maildir/.Ham/cur/
    Second I would like to perform the rm command in the same way with the additional change to only deleteing files that are two days old or older.

    Psuedocode:
    Code:
    rm -f /home/vpopmail/domains/*/*/Maildir/{.Junk}{.Ham}/cur/* THAT ARE < (TODAY-1 day)
    I am still very green when it come to bash scripting and reg exp's, so any help in creating this script would be appreciated along with a step by step explanation of each command, esp the description of any reg exps.

    Thanks

    Skydiver

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I'm not sure that I understand the wildcard issue. What is the reason that you cannot use the exact syntax that you wrote yourself?

    As for the removing issue, however, the easiest way to do that is probably with the `find' command. For example, like this:
    Code:
    find /home/vpopmail/domains/*/*/Maildir/.{Junk,Ham}/cur -mtime +2 -type f -exec rm -f {} \;

  3. #3
    Just Joined!
    Join Date
    Jan 2006
    Posts
    3
    The reason is that as I add new users in different domains, I do not wish to have to manaully add a new setting for each user. I am hosting a domain for a friend that is in charge of creating his own users. I would prefer that the script acts on the Maildir/.Junk/cur for every user in every domain. Once I get the wildcard solution set up I think that will work with the find command to remove file over two days old.

    Can I not use a wildcard such as I described here? If not, what kind of psuedocode logic would I need to use to create the script?

  4. #4
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I do believe that the wildcard example you wrote yourself should work perfectly (unless I have somehow misunderstood you). Just to be sure that we aren't talking about two different things, this is the one I mean:
    Code:
    sa-learn --showdots --no-sync --spam /home/vpopmail/domains/*/*/Maildir/.Junk/cur/

  5. #5
    Just Joined!
    Join Date
    Jan 2006
    Posts
    3
    Your absolutely right! I didn't realize you could use wildcards this way (Throwback to windoze limitations).

    Thanks for you help!

Posting Permissions

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