Results 1 to 3 of 3
I would like to create a script that will run every day and save all the messages in the inbox and save them to a file then delete the old ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 04-09-2012 #1
bash script - save mailbox messages.
I would like to create a script that will run every day and save all the messages in the inbox and save them to a file then delete the old messages.
Right now I am doing this manually and would like this automated. This is how I am doing it now.
I go to my mail archive folder and type:
mail
> s 1-### mbox.temp###
> d 1-###
> q
Now if the number of messages were the same everyday then I would be able to do this a lot easier. Since I dont know if there is any wild cards I could use for the total number of messages does anyone know another way to do this?
Thanks
- 04-14-2012 #2Just Joined!
- Join Date
- May 2011
- Location
- Central FL
- Posts
- 80
That would copy the current mbox to a new file (gzip it - just because saving space doesn't hurt), then clear the old mbox. You could just create a file with those contents and run it once daily via cron.Code:#!/bin/sh cp mbox mbox.`date +%F` && gzip mbox.`date +%F` && : > mbox
Last edited by dayid; 04-14-2012 at 02:11 AM. Reason: clarify
- 07-27-2012 #3
well I know this is old but I figured out how to do it. It was so simple I feel bad that I didn't think of it sooner. The good new is I have automated this process and removed it from my daily tasks.
first i run
to save the email to a file called newmail.fileCode:cp /var/spool/mail/<username> newmail.file
then I run
to delete the mailCode:> /var/spool/mail/<username>



