1825750 Members
2344 Online
109687 Solutions
New Discussion

Re: Clear logs

 
SOLVED
Go to solution
Allanm
Super Advisor

Clear logs


I am doing some housekeeping and clearing up some archived logs ,firstly I am using the pax command to copy stuff over so that I can copy the directory structure also. Then I issue the rm command after the job is completed to clear up space.

Here is what I am doing :

nohup /usr/bin/pax -rw bo/app/*2006* /logsfs/logs/archive/prod &

and then the rm command :
rm -fr *2006*

Can I do this in one single piped command.

Please suggest.
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor
Solution

Re: Clear logs

Hi:

To execute the file removal only upon successful completion of the 'pax':

# /usr/bin/pax -rw bo/app/*2006* /logsfs/logs/archive/prod && rm -fr *2006*

Regards!

...JRF...
Allanm
Super Advisor

Re: Clear logs


Thanks JRF!

And what if I need to have it mail me once done with pax and rm.
James R. Ferguson
Acclaimed Contributor

Re: Clear logs

Hi (again):

> And what if I need to have it mail me once done with pax and rm.

You could simply do:

# /usr/bin/pax -rw bo/app/*2006* /logsfs/logs/archive/prod && { rm -fr *2006*; mailx -s "Logs cleared" root < /dev/null; }

That is, if the 'pax' is successful; run the subshell process which removes the logs and mails the 'root' user a message.

Regards!

...JRF...
Allanm
Super Advisor

Re: Clear logs


I would want to run all this as nohup though.