The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Newsgroups: comp.unix.shell
From:
contrace... @gmail.com
Date: Mon, 8 Oct 2012 12:26:24 -0700 (PDT)
Local: Mon, Oct 8 2012 3:26 pm
Subject: Deleting old files
Hi,
Please help me to fix this script, I need delete old files (> 90 days)
#!/bin/ksh
set -x
SIZE=`df -P /home/devalias | grep -v Filesystem | awk '{ print $5 }' | tr -d %`
if [[ $SIZE -gt "10" ]]
then
/usr/bin/find /home/devalias/transfer* -type f -name "*.txt" -mtime +90 -exec rm -f {} \;
/usr/bin/find /home/devalias/transfer* -type f -name "*.cfm" -mtime +90 -exec rm -f {} \;
fi
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.unix.shell
From:
Barry Margolin <bar... @alum.mit.edu>
Date: Mon, 08 Oct 2012 15:54:47 -0400
Local: Mon, Oct 8 2012 3:54 pm
Subject: Re: Deleting old files
In article <06f77a1c-e04c-4551-88b8-de11f841dff6@googlegroups.com>,
contrace
... @gmail.com wrote:
> Hi,
> Please help me to fix this script, I need delete old files (> 90 days)
> #!/bin/ksh
> set -x
> SIZE=`df -P /home/devalias | grep -v Filesystem | awk '{ print $5 }' | tr -d > %`
> if [[ $SIZE -gt "10" ]]
> then
> /usr/bin/find /home/devalias/transfer* -type f -name "*.txt" -mtime +90 -exec > rm -f {} \;
> /usr/bin/find /home/devalias/transfer* -type f -name "*.cfm" -mtime +90 -exec > rm -f {} \;
> fi
What's wrong with it? I can see ways to improve it, but I don't see any
serious problems with it.
You can combine the two finds into one, and run rm only once with all the filenames, with:
/usr/bin/find /home/devalias/transfer* -type f \( -name '*.txt' -o -name '*.cfm' \) -mtime +90 -exec rm -f {} +
And awk can do its own grepping and tr'ing:
SIZE=`df -P /home/devalias | awk '!/Filesystem/ {gsub("%", "", $5); print $5}'`
-- Barry Margolin, bar... @alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.unix.shell
From:
contracer <contrace... @gmail.com>
Date: Tue, 9 Oct 2012 13:11:06 -0700 (PDT)
Local: Tues, Oct 9 2012 4:11 pm
Subject: Re: Deleting old files
On 8 out, 16:54, Barry Margolin <bar
... @alum.mit.edu> wrote:
> In article <06f77a1c-e04c-4551-88b8-de11f841dff6@googlegroups.com>,
> contrace... @gmail.com wrote:
> > Hi,
> > Please help me to fix this script, I need delete old files (> 90 days)
> > #!/bin/ksh
> > set -x
> > SIZE=`df -P /home/devalias | grep -v Filesystem | awk '{ print $5 }' | tr -d
> > %`
> > if [[ $SIZE -gt "10" ]]
> > then
> > /usr/bin/find /home/devalias/transfer* -type f -name "*.txt" -mtime +90 -exec
> > rm -f {} \;
> > /usr/bin/find /home/devalias/transfer* -type f -name "*.cfm" -mtime +90 -exec
> > rm -f {} \;
> > fi
> What's wrong with it? I can see ways to improve it, but I don't see any
> serious problems with it.
> You can combine the two finds into one, and run rm only once with all
> the filenames, with:
> /usr/bin/find /home/devalias/transfer* -type f \( -name '*.txt' -o -name
> '*.cfm' \) -mtime +90 -exec rm -f {} +
> And awk can do its own grepping and tr'ing:
> SIZE=`df -P /home/devalias | awk '!/Filesystem/ {gsub("%", "", $5);
> print $5}'`
> --
> Barry Margolin, bar... @alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***- Ocultar texto das mensagens anteriores -
> - Mostrar texto das mensagens anteriores -
I donīt know how, but find commands arenīt deleting old files...
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.unix.shell
From:
Lem Novantotto <Le... @Hotmail.com>
Date: 09 Oct 2012 20:22:05 GMT
Local: Tues, Oct 9 2012 4:22 pm
Subject: Re: Deleting old files
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.unix.shell
From:
contracer <contrace... @gmail.com>
Date: Tue, 9 Oct 2012 13:29:22 -0700 (PDT)
Local: Tues, Oct 9 2012 4:29 pm
Subject: Re: Deleting old files
On 9 out, 17:22, Lem Novantotto <Le
... @Hotmail.com> wrote:
12
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.unix.shell
From:
Lem Novantotto <Le... @Hotmail.com>
Date: 10 Oct 2012 07:35:36 GMT
Local: Wed, Oct 10 2012 3:35 am
Subject: Re: Deleting old files
contracer ha scritto:
> 12
Ok. And the output of:
/usr/bin/find /home/devalias/transfer* -type f -name "*.txt" -mtime +90
and of:
/usr/bin/find /home/devalias/transfer* -type f -name "*.cfm" -mtime +90
If find doesn't find any files, there are no files to delete.
If, on the contrary, some files are found, then:
- try using "-delete" instead of "-exec rm -f {} \;"
- try to delete one of them manually. What happens?
- has the user who runs this script the rights to delete these files?
- are these files immutable? Check with lsattr
- on which kind of filesystem are the files? Which options is it mounted with?
-- Bye, Lem
Ceterum censeo ISLAM esse delendum
_________________________________________________________________
Non sprecare i cicli idle della tua CPU, né quelli della tua GPU.
http://www.worldcommunitygrid.org/index.jsp
http://www.rnaworld.de/rnaworld/ http://home.edges-grid.eu/home/
http://www.gpugrid.net/
You must
Sign in before you can post messages.
You do not have the permission required to post.