I'd like to be able to do the following as user cg:-
mv /var/mail/cg ~/backup/mail
Now I know I can't actually do this because /var/mail is owned by mail and cg doesn't have write permission there. Is there any way that I can set things up so that 'cg' can do it or is there an alternative that produces the same result?
I could do something like:-
cp /var/mail/cg ~/backup/mail cp emptyFile /var/mail/cg
This would have the same effect *except* that it's not atomic so if mail arrives between the cp commands it would get lost.
What I'm trying to do is have a crude backup of my incoming mail, I forward all my incoming mail to 'cg' as well as to myself and want to run a cron job to do the above 'move' once a week so that all my mail for the last seven days is in /var/mail/cg and mail for the previous seven days is in /home/cg/backup/mail.
I could run the cron job as root I suppose, that would do what I want, but I'm just looking for neater/safer ways of doing it.
On Tue, Mar 24, 2009 at 09:27:15PM +0000, Chris G wrote:
I'd like to be able to do the following as user cg:-
mv /var/mail/cg ~/backup/mail
Now I know I can't actually do this because /var/mail is owned by mail and cg doesn't have write permission there. Is there any way that I can set things up so that 'cg' can do it or is there an alternative that produces the same result?
I could do something like:-
cp /var/mail/cg ~/backup/mail cp emptyFile /var/mail/cg
This would have the same effect *except* that it's not atomic so if mail arrives between the cp commands it would get lost.
What I'm trying to do is have a crude backup of my incoming mail, I forward all my incoming mail to 'cg' as well as to myself and want to run a cron job to do the above 'move' once a week so that all my mail for the last seven days is in /var/mail/cg and mail for the previous seven days is in /home/cg/backup/mail.
I could run the cron job as root I suppose, that would do what I want, but I'm just looking for neater/safer ways of doing it.
Alternatively of course I may do something like the answer to my previous question here:-
On Fri, Mar 13, 2009 at 01:56:22PM +0000, MJ Ray wrote: > Chris G cl@isbd.net wrote: > > Can anyone suggest a neat/easy way to keep only (say) the last seven > > days of messages in an incoming mail spool? > > Install Heirloom mailx, then > date -d '7 days ago' '+d (before %d-%b-%Y)' | mailx -f path/to/mbox > > Replace mailx with nail for older versions of debian and ubuntu, but > I'm not sure in which version the () style of selection appeared. > Excellent, thanks, that looks like just what I need.