Author Topic: email cron  (Read 2644 times)

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
email cron
« on: July 31, 2012, 10:12:51 PM »
Does anyone know how to write a cron job that will delete emails in the inbox and sent folders that are more than say 3 months old?

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: email cron
« Reply #1 on: July 31, 2012, 10:28:07 PM »
Do you have IMAP access?

edit: Or is this going to be ran on the email server itself? If so what software are you using?

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: email cron
« Reply #2 on: July 31, 2012, 10:36:38 PM »
Cron jobs are a valuable skill to learn if you are going to be working with servers.
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: email cron
« Reply #3 on: July 31, 2012, 10:48:02 PM »
Do you have IMAP access?

edit: Or is this going to be ran on the email server itself? If so what software are you using?
My client is using MAC Mail which apparently doesn't work very well as far as purging mail after x months.

I'm running this directly on the server.  I am not using any software, just direct command line/cron.

I found the path to the folder:

/home/user/mail/domain/account/cur = inbox
/home/user/mail/domain/account/.Sent = sent messages

so now i can just use:

find /path/to/files* -mtime +200 -exec rm {} \;

Sweet.  :)

Cron jobs are a valuable skill to learn if you are going to be working with servers.
I know how to setup cron jobs... I have over 30 running on this server alone.  My linux command line and mail folder structure knowledge is what was lacking.

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: email cron
« Reply #4 on: July 31, 2012, 10:54:28 PM »
Do you have IMAP access?

edit: Or is this going to be ran on the email server itself? If so what software are you using?
My client is using MAC Mail which apparently doesn't work very well as far as purging mail after x months.

I'm running this directly on the server.  I am not using any software, just direct command line/cron.
Sorry I meant, what software your MTA was (which in turn helps points to where the files are.

Quote
I found the path to the folder:

/home/user/mail/domain/account/cur = inbox
/home/user/mail/domain/account/.Sent = sent messages

so now i can just use:

find /path/to/files* -mtime +200 -exec rm {} \;

Sweet.  :)
Isn't find awesome?

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: email cron
« Reply #5 on: August 01, 2012, 08:45:31 AM »
I'm not actually sure what mail service this web host is running, but I assume most linux mail file structures are similar.

find is awesome.  :)

webwhy

  • Jackass IV
  • Posts: 608
  • Karma: +15/-10
Re: email cron
« Reply #6 on: August 01, 2012, 12:22:30 PM »
FYI two main formats in the unix world.

maildir and mbox

mbox is the older format, mail is stored in one large file (the mailbox) so you would need another set of text processing commands and lock the file properly to achieve the same result.  i think most sysadmins are using maildir these days.

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: email cron
« Reply #7 on: August 01, 2012, 12:23:22 PM »
Yeah, this setup uses directories and each email is a file.

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: email cron
« Reply #8 on: August 01, 2012, 02:54:10 PM »
Cron jobs are a valuable skill to learn if you are going to be working with servers.
I know how to setup cron jobs... I have over 30 running on this server alone.  My linux command line and mail folder structure knowledge is what was lacking.
[/quote]

My bad
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?