LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-04-2012, 06:54 AM   #1
zodehala
Member
 
Registered: Nov 2008
Posts: 53

Rep: Reputation: 15
auto delete older den 45 days


i can delete like following .

Code:
#!/usr/bin/perl
@lines=`ls -1 /var/spool/asterisk/monitor/*in.wav`;
foreach $line (@lines){
    (@splits)=split("in.wav",$line);
    chop(@splits[0]);
    $base=@splits[0];
    $base=~ s/(")/\\\"/g;
    $base=~ s/( )/\\\ /g;
    $base=~ s/(>)/\\\>/g;
    $base=~ s/(<)/\\\</g;
    print `soxmix $base-in.wav $base-out.wav $base.wav`;
    `rm -f $base-*`;


}
how can i delete wav files older than 45 days automatically
(any short form above code ?)

Last edited by zodehala; 02-04-2012 at 06:56 AM.
 
Old 02-04-2012, 07:23 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
no need for any perl here...

find /path/to/files -iname '*.wav' -ctime +45 -exec rm -f {}\;
 
1 members found this post helpful.
Old 02-04-2012, 07:50 AM   #3
zodehala
Member
 
Registered: Nov 2008
Posts: 53

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by acid_kewpie View Post
no need for any perl here...

find /path/to/files -iname '*.wav' -ctime +45 -exec rm -f {}\;
automatically ? if yes how will i delete this script ?

it gives error

Code:
[root@tekopbx ~]# find /var/spool/asterisk/monitor/ -iname '*.wav' -ctime +45 -exec rm -f {}\;
find: missing argument to `-exec'
[root@tekopbx ~]#

Last edited by zodehala; 02-04-2012 at 08:05 AM.
 
Old 02-04-2012, 09:05 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Hi,

I do believe you need a space between {} and \;
Code:
find /var/spool/asterisk/monitor/ -iname '*.wav' -ctime +45 -exec rm -f {} \;
Hope this helps.
 
Old 02-04-2012, 10:16 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
Quote:
Originally Posted by druuna View Post
Hi,

I do believe you need a space between {} and \;
Code:
find /var/spool/asterisk/monitor/ -iname '*.wav' -ctime +45 -exec rm -f {} \;
Hope this helps.
DOH! yes...
 
  


Reply


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
delete files when it's older 30 days Madison00 Linux - Newbie 8 01-07-2011 02:07 AM
[SOLVED] Delete old files older than 7 days rjo98 Linux - Newbie 3 09-18-2009 01:15 PM
Delete files older then 30 days stefaandk *BSD 1 01-07-2008 08:31 PM
script to auto delete files older than X days nocnoc Programming 17 12-06-2006 08:30 AM
delete files older than 30 days using cronjob latheesan Linux - Newbie 5 06-14-2005 02:40 PM


All times are GMT -5. The time now is 03:39 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration