LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   [SOLVED] Bash: Script for cleaning Voicemails from Asterisk. (http://www.linuxquestions.org/questions/programming-9/%5Bsolved%5D-bash-script-for-cleaning-voicemails-from-asterisk-802276/)

Mortuus 04-15-2010 05:01 PM

[SOLVED] Bash: Script for cleaning Voicemails from Asterisk.
 
Hi all!

I have to clean the voicemails from asterisk, but I want to keep at least, the voicemails for five days.

I started writing a script, but I'm a bit stuck, and I've trying somethings for sometime, but still I can't get it

The hierarchy of Asterisk Voicemails is like this:
  • default
  • 10000
  • INBOX
  • msgbox0001.txt
  • msgbox0001.wav
  • msgbox0002.txt
  • msgbox0002.wav
  • 10004
  • INBOX
  • msgbox0001.txt
  • msgbox0001.wav
  • msgbox0002.txt
  • msgbox0002.wav
  • 10040
  • INBOX
  • msgbox0001.txt
  • msgbox0001.wav
  • msgbox0002.txt
  • msgbox0002.wav

etc...

I did a
Code:

cat default > folderlist
to have all the names of the folders

Then I thought that I could do a while loop like this
Code:

while read line
do
cd var/spool/asterisk/voicemail/default/$line/INBOX
pwd # this is just for testing that works
done < folderlist

But I don't know how I can compare dates for deleting only the voicemails that are older than 5 days.

:S


Thanks for your helping, I really aprecciate it


Thanks again

Sergei Steshenko 04-15-2010 06:23 PM

Quote:

Originally Posted by Mortuus (Post 3936960)
...
But I don't know how I can compare dates for deleting only the voicemails that are older than 5 days.
...


Read

man find

.

jchambers 04-16-2010 03:16 AM

This looks like it may work.

http://www.unix.com/tips-tutorials/3...tion-bash.html

Mortuus 04-16-2010 01:19 PM

Thanks both of you!

I've already solved it with find :D

Thanks again!

grail 04-17-2010 01:56 AM

Great you have a solution, please mark as SOLVED.


All times are GMT -5. The time now is 10:21 AM.