Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
Ŧ Groups Home
Deleting old files
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
contrace...@gmail.com  
View profile  
 More options Oct 8 2012, 3:26 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Margolin  
View profile  
 More options Oct 8 2012, 3:54 pm
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>,

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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
contracer  
View profile  
 More options Oct 9 2012, 4:11 pm
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:

I donīt know how, but find commands arenīt deleting old files...

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lem Novantotto  
View profile  
 More options Oct 9 2012, 4:22 pm
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
contracer ha scritto:

> I donīt know how, but find commands arenīt deleting old files...

Please show the output of:

df -P /home/devalias | grep -v Filesystem | awk '{ print $5 }' | tr -d %

--
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
contracer  
View profile  
 More options Oct 9 2012, 4:29 pm
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:

> contracer ha scritto:

> > I donīt know how, but find commands arenīt deleting old files...

> Please show the output of:

> df -P /home/devalias | grep -v Filesystem | awk '{ print $5 }' | tr -d %

> --
> 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.jsphttp://www.rnaworld.de/rna...http://home.edges-grid.eu/home/
>                    http://www.gpugrid.net/

12

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lem Novantotto  
View profile  
 More options Oct 10 2012, 3:35 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »