LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-15-2010, 05:01 PM   #1
Mortuus
LQ Newbie
 
Registered: Mar 2010
Location: Madrid, Spain
Distribution: Debian Testing
Posts: 21

Rep: Reputation: 0
[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

Last edited by Mortuus; 04-18-2010 at 09:36 AM.
 
Old 04-15-2010, 06:23 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Mortuus View Post
...
But I don't know how I can compare dates for deleting only the voicemails that are older than 5 days.
...

Read

man find

.
 
1 members found this post helpful.
Old 04-16-2010, 03:16 AM   #3
jchambers
Member
 
Registered: Aug 2007
Location: California
Distribution: Debian
Posts: 127

Rep: Reputation: 15
This looks like it may work.

http://www.unix.com/tips-tutorials/3...tion-bash.html
 
Old 04-16-2010, 01:19 PM   #4
Mortuus
LQ Newbie
 
Registered: Mar 2010
Location: Madrid, Spain
Distribution: Debian Testing
Posts: 21

Original Poster
Rep: Reputation: 0
Thanks both of you!

I've already solved it with find

Thanks again!
 
Old 04-17-2010, 01:56 AM   #5
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,442

Rep: Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880
Great you have a solution, please mark as SOLVED.
 
  


Reply

Tags
asterisk, bash, deleting, scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cleaning up my first bash script altup Linux - Newbie 2 09-15-2009 03:26 PM
script for cleaning log Imranteli Linux - Newbie 3 09-10-2009 11:25 PM
How to pass commands to asterisk CLI via bash script? Lordmonkey Linux - Newbie 3 03-24-2009 08:59 AM
bash asterisk variable substitution bt101 Linux - Software 3 02-08-2009 11:37 PM
cleaning the readability of this ruby script hedpe Programming 1 12-26-2006 02:46 PM


All times are GMT -5. The time now is 08:19 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration