Operating System - HP-UX
1834645 Members
1998 Online
110069 Solutions
New Discussion

Re: Purge old directories on Ignite server

 
SOLVED
Go to solution
IT_2007
Honored Contributor

Purge old directories on Ignite server

Need to find and purge old directories which are getting created whenever make_net_recovery script run for client backups. Those are stored on Ignite Server at /var/opt/ignite/clients/`hostname`/recovery

Example:

# ll
total 24
drwxr-xr-x 2 bin bin 4096 Aug 11 15:39 2006-08-11,15:36
drwxr-xr-x 2 bin bin 4096 Aug 18 08:19 2006-08-18,07:53
-rw-r--r-- 1 bin sys 290 Aug 18 08:19 client_status
lrwxr-xr-x 1 bin bin 16 Aug 18 07:53 latest -> 2006-08-18,07:53

make_net_recovery won't delete old directories and just creates new one and links to latest. I have 100 hosts whose backups are stored on Ignite server. Don't want to do manually.

I want to keep latest two directories only.

BTW, archive images are stored on /archives directory and I run make_net_recovery to keep two images on this directory with -n 2 option.



7 REPLIES 7
James R. Ferguson
Acclaimed Contributor
Solution

Re: Purge old directories on Ignite server

Hi:

You could simply select the directories in timestamp sequence:

# ls -lt /var/opt/ignite/clients/`hostname`/recovery | grep "^d" | tail +3

...look only for directories and trim the list to the ones you want to remove.

Regards!

...JRF...
IT_2007
Honored Contributor

Re: Purge old directories on Ignite server

Thanks.. got it.
IT_2007
Honored Contributor

Re: Purge old directories on Ignite server

ok. I thought I posted my question. but ITRC website really sucks.

anyway, I want to automate the following script for a bunch of 30 hosts.
I tried this way but not working.

for i in `cat hosts.txt`
do
ls -lt /var/opt/ignite/clients/$i/recovery | grep "^d" |tail +3 |awk
'{print $9}' |xargs -n 1 rm -rf
done

I know rm isn't taking absolute path. How do I modify above script to read absolute path?
Yang Qin_1
Honored Contributor

Re: Purge old directories on Ignite server

How about:

for i in `cat hosts.txt`
do
cd /var/opt/ignite/clients/$i/recovery
ls -lt | grep "^d" |tail +3 |awk
'{print $9}' |xargs -n 1 rm -rf
done

Regards,
Yang
IT_2007
Honored Contributor

Re: Purge old directories on Ignite server

nope. It doesn't work. It still didn't removed it.
James R. Ferguson
Acclaimed Contributor

Re: Purge old directories on Ignite server

Hi:

For you 'xargs' use:

...

# xargs -i rm -rf $PWD/{}

Regards!

...JRF...
IT_2007
Honored Contributor

Re: Purge old directories on Ignite server

sorry. My bad. It worked. Thanks a bunch.