Prev: advice request, migrating from Fedora to Mint
Next: NetStatsBaseball v0.9.6 Released DOWNLOAD !
From: Riccardo on 25 May 2010 03:04 I'm using shell script which help me to keep a copy of my mailbox for last N days (e.g. 40 days), so I need unique total file which will contain msg about last 40 days. I'm going to schedule a crontab task which will start every day at the same time. How can I create script file, where every time script starts (every day), I have to replace from total file the part which contains data about the 40th day with that one which contains latest data ? Do you know if it exist shell commands to work with SUBTRACTION among files ?
From: Grant on 25 May 2010 03:41 On Tue, 25 May 2010 00:04:07 -0700 (PDT), Riccardo <ric.castellani(a)alice.it> wrote: >I'm using shell script which help me to keep a copy of my mailbox for >last N days (e.g. 40 days), so I need unique total file which will >contain msg about last 40 days. >I'm going to schedule a crontab task which will start every day at the >same time. > >How can I create script file, where every time script starts (every >day), I have to replace from total file the part which contains data >about the 40th day with that one which contains latest data ? >Do you know if it exist shell commands to work with SUBTRACTION among >files ? Think of it more in terms of adding the to head of the file, then chopping off a piece of the tail? So you could write today's to a new temp file, append first 39 days from total (now 2nd to 40th day) to the temp, rename (mv) temp to total. Grant. -- http://bugs.id.au/
From: Riccardo on 25 May 2010 04:57 On 25 Mag, 09:41, Grant <o...(a)grrr.id.au> wrote: > On Tue, 25 May 2010 00:04:07 -0700 (PDT), Riccardo <ric.castell...(a)alice.it> wrote: > >I'm using shell script which help me to keep a copy of my mailbox for > >last N days (e.g. 40 days), so I need unique total file which will > >contain msg about last 40 days. > >I'm going to schedule a crontab task which will start every day at the > >same time. > > >How can I create script file, where every time script starts (every > >day), I have to replace from total file the part which contains data > >about the 40th day with that one which contains latest data ? > >Do you know if it exist shell commands to work with SUBTRACTION among > >files ? > > Think of it more in terms of adding the to head of the file, then > chopping off a piece of the tail? > > So you could write today's to a new temp file, append first 39 days > from total (now 2nd to 40th day) to the temp, rename (mv) temp to total. > > Grant. > --http://bugs.id.au/ Well, that's a good idea but how can I detect 39 days (2nd to 40th) into total file ? My mailbox is always feed from messages , so every day I can copy this mailbox to temp file (today) and then I can erase it for populating again. I can accumulate msg into total file, appending every day "temp file" to "total file", but I cannot distinguish msg for data because cron start at specific time
From: Bit Twister on 25 May 2010 06:42 On Tue, 25 May 2010 01:57:28 -0700 (PDT), Riccardo wrote: > > Well, that's a good idea but how can I detect 39 days (2nd to 40th) > into total file ? Store day counter in a file. Use it for decisions. _counter_fn=/some/where/day.counter if [ ! -e $_counter_fn ] ; then echo "day=0" > $_counter_fn fi .. $_counter_fn let day="day + 1" echo "day=$day" > $_counter_fn #********************* #* daily goes code here #********************* if [ $day -lt 40 ] ; then exit 0 fi echo "day=0" > $_counter_fn #************************* #* day 40 code goes here #************************* > I can accumulate msg into total file, appending every day "temp file" > to "total file", but I cannot distinguish msg for data because cron > start at specific time Well, at day 40 add in whatever you like. Example: echo " #************* #* $(date) #************* " >> $_total_fn
From: Matt Giwer on 25 May 2010 20:06 On 05/25/2010 03:04 AM, Riccardo wrote: > I'm using shell script which help me to keep a copy of my mailbox for > last N days (e.g. 40 days), so I need unique total file which will > contain msg about last 40 days. > I'm going to schedule a crontab task which will start every day at the > same time. > How can I create script file, where every time script starts (every > day), I have to replace from total file the part which contains data > about the 40th day with that one which contains latest data ? > Do you know if it exist shell commands to work with SUBTRACTION among > files ? What mail program are you using? It is generally only two files, one that contains the messages and the other an index to it. Why not set the software for a 40 day retention policy and then simply copy those two files? No use making work for yourself. -- All squattertowns beyond the Green Line are considered by the world to be criminal. Why are not those who live in them arrested as criminals? -- The Iron Webmaster, 4253 http://www.giwersworld.org/israel/is-seg.phtml a14 Tue May 25 20:00:43 EDT 2010
|
Pages: 1 Prev: advice request, migrating from Fedora to Mint Next: NetStatsBaseball v0.9.6 Released DOWNLOAD ! |