1830898 Members
3069 Online
110017 Solutions
New Discussion

cpio output to a file?

 
SOLVED
Go to solution
Greg Stark_1
Frequent Advisor

cpio output to a file?

I use cpio to backup some directories to a local tape drive with the following command:

find ${SITES} -print |cpio -C300ov > $TAPE_DRIVE

${SITES} is a variable of directories.

I also have a logfile that I write to throughout the scrit to note current date, success/failure, etc... How do I get the output of the cpio command (i.e. the directories that are being backup up) to the logfile?

I have made a few attempts with "tee" and "exec" but haven't had any luck yet.

Thanks again,
Greg
5 REPLIES 5
harry d brown jr
Honored Contributor

Re: cpio output to a file?

add this to the end of your command 2>&1 1>/logspath/cpiologname


live free or die
harry
Live Free or Die
Joseph C. Denman
Honored Contributor

Re: cpio output to a file?

hmmm....
I'm sure there is a better way, but off the top of my head.
how about:

find ${SITES} -print > /tmp/filelist.tmp;cat /tmp/filelist.tmp >> $logfile; cat /tmp/filelist.tmp|cpio -C300ov > $TAPE_DRIVE

...jcd...



If I had only read the instructions first??
A. Clay Stephenson
Acclaimed Contributor

Re: cpio output to a file?

Hi:

You are very close.

find ${SITES} -print |cpio -C300ov > ${TAPE_DRIVE} 2>/var/tmp/mylog

The '-v' list is going to stderr.

Regards, Clay

If it ain't broke, I can fix that.
Sanjay_6
Honored Contributor
Solution

Re: cpio output to a file?

Hi Greg,

Try,

find ${SITES} -print |tee -e log_file |cpio -C300ov > $TAPE_DRIVE

Hope this helps.

Regds
Sanjay_6
Honored Contributor

Re: cpio output to a file?

Hi Greg,

Sorry, the option is -a and not -e as mentioned in my earlier post.

find ${SITES} -print |tee -a log_file |cpio -C300ov > $TAPE_DRIVE

hope this helps.

Regds