1830207 Members
1381 Online
109999 Solutions
New Discussion

testing failed..

 
pauline_1
Occasional Advisor

testing failed..

i did this~ :
cd ${WKDIR}
find s* -mtime +90 -exec rm -f {} \;
echo "###gzip files###"
gzip `find $WKDIR -mtime +30 -print||more`
if [ -z *gz ]; then
echo "###tar files###"
tar -cvf Archive_${DATE}.tar *gz
fi
echo "###move all tar files to $FINDIR###"
mv *tar ${FINDIR}
echo "###$FINDDIR deleting tar files that is more than three months###"
cd ${FINDIR}
find *tar -mtime +90 -exec rm -f {} \;
echo "###end of removing file .. done###"

i tested it .. but it failed. what can be the prblem ?
9 REPLIES 9
pauline_1
Occasional Advisor

Re: testing failed..

ps: this script is written with refernce to the previous msg i posted "Unix Shell Script"
on 21 May 2002
Steven Sim Kok Leong
Honored Contributor

Re: testing failed..

Hi,

The error messages will be able to give you some clues. What are the error messages?

Hope this helps. Regards.

Steven Sim Kok Leong
A. Clay Stephenson
Acclaimed Contributor

Re: testing failed..

Without bothering to look at your other posting, I feel rather certain that your problem centers on your find statements.

cd ${WKDIR}
find s* -mtime +90 -exec rm -f {} \;

I suspect that you really meant something like this:

find . -name 's*' -mtime +90 -exec rm -f {} \;


If it ain't broke, I can fix that.
MANOJ SRIVASTAVA
Honored Contributor

Re: testing failed..

Hi Pauline

The first thing that you do is to add !/usr/bin/ksh -x so that it will run in debug mode and will echo after every coomand as to what is going right or wrong .That way oit becaome very convieneint to solve the issue.
Also just try running the find command alone , I think that is the problem .

find . -name s* -print should be the format .


Manoj Srivastava
Steven Sim Kok Leong
Honored Contributor

Re: testing failed..

Hi,

Now that I have got the time to take a look at your code, your two find statements are using the wrong syntax. Clay has already pointed out one:

find s* -mtime +90 -exec rm -f {} \;

The other one that has not been pointed out is:

find *tar -mtime +90 -exec rm -f {} \;

which should be phrased correctly as:

find $DIR -name *tar -mtime +90 -exec rm -f {} \;

Hope this helps. Regards.

Steven Sim Kok Leong
pauline_1
Occasional Advisor

Re: testing failed..

i tried to use this:

find $DIR -name *tar -mtime -print;

but there is this error msg:
"Find: missing conjunction"

whats wrg with this statement?
Wodisch
Honored Contributor

Re: testing failed..

Hi Pauline,

your "find s* ..." is fine if your really intend to only traverse subdirectories which names begin with an "s", do you?
Then you should always use quoting around wildcards, that's the reason for the failure your mentioned just above this reply.
And finally I am quite certain you did not want to use a double-pipe in the "gzip" line...

Run the script after executing "set -x ; set -v; exec > out.txt 2>&1" and attach the output.

Just my $0.02,
Wodisch
Peter Kloetgen
Esteemed Contributor

Re: testing failed..

Hi Pauline,

the last error you have to remove is the following:

--> find: missing conjunction, if you use variables with this command, you have to quote them:

find "$DIR" -name *tar -mtime +90 -exec rm {};


Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Peter Kloetgen
Esteemed Contributor

Re: testing failed..

Hi Pauline,

sorry, once again, typo in last posting...

the command line has to look so:

find "$DIR" -name *tar -mtime +90 -exec rm {}\;


Allways stay on the bright side of life!

Peter
I'm learning here as well as helping