Operating System - HP-UX
1751976 Members
4740 Online
108784 Solutions
New Discussion юеВ

Re: Can I set a timeout to cp?

 
SOLVED
Go to solution
A. Clay Stephenson
Acclaimed Contributor

Re: Can I set a timeout to cp?

Vxfs snapshots are very easy.

For example to create a snapshort of /u01/oradata (we will call it /u01/snaporadata), you do this:

mkdir /u01/snaporadata
mount -F vxfs -o snapof=/u01/oradata /dev/vg05/lvol1 /u01/snaporadata

That's it. The mysterious /dev/vg05/lvol1 is an otherwise unused LVOL or disk that is used as the snapshot buffer. It should be sized to about 15% or so of the original filesystem. The "snapshot" does not copy the original filesystem but is a composite of unchanged blocks from the original filesystem plus the original contents of any changed blocks (since the snapshot was started) recorded in the snapshot buffer.

To remove the snapshot all you do is unmount it.
umount /u01/snaporadata
rmdir /u01/snaporadata

Man mount_vxfs for deails. Note: Snapshots require the OnlineJFS product but no HP-UX box should be without OnlineJFS anyway.
If it ain't broke, I can fix that.
Eric Antunes
Honored Contributor

Re: Can I set a timeout to cp?

Hi Clay,

Can you explain me better the phrase "no HP-UX box should be without OnlineJFS anyway."? I may need it to justify this purchase.

Thanks,

Eric Antunes

Each and every day is a good day to learn.
A. Clay Stephenson
Acclaimed Contributor

Re: Can I set a timeout to cp?

The main advantage of OnlineJFS is that it allows online expansion of filesystems. Unless you have OnlineJFS, you would have to unmount the filesystem first and if it's a system filesystem (e.g. /var, /usr, /tmp) you would have to knock the box down to single-user mode. It also allows much better sizing of filesystems because you don't have to deliberately oversize the filesystem initially because expansion is so easy. How many times have you setup systems with one filesystem much larger then needed and another that needs expansion? You can also use OnlineJFS to reduce the size of a filesystem "on the fly" although that was a bit risky until recent versions of VxFS>
If it ain't broke, I can fix that.
Sandman!
Honored Contributor

Re: Can I set a timeout to cp?

Your script should initialize the exit_code variable otherwise the test will fail...

>
> exit_code = 1
> while [ $exit_code -eq 1 ]
>


cheers!
Eric Antunes
Honored Contributor

Re: Can I set a timeout to cp?

Hi all,

I did it with the following script:


WAIT_TIME=30
TIMEOUT=300
TIMER=0

ORIGEM=/disc1/oradata/TST
DESTINO=/_disc2/
exit_code=1

cp -Rp $ORIGEM/* $DESTINO
exit_code=$?

while [ $exit_code -eq 1 ]
do
echo "waiting for backup...\n"
sleep ${WAIT_TIME}
TIMER=`expr $TIMER + ${WAIT_TIME}`
if [ $TIMER -ge $TIMEOUT ]
then
echo "\nWARNING: backup NOT EXECUTED!\n";
exit_code=8;
fi
done

echo "\nSUCCESS! Backup executed!!\n"


PS: Indira please post something since the base script is yours...

Best Regards,

Eric Antunes
Each and every day is a good day to learn.
Muthukumar_5
Honored Contributor

Re: Can I set a timeout to cp?

Eric,

You are setting TIMEOUT after cp operation getting completed based upon cp command return status.

If you want to set TIMEOUT for cp operation while occuring, then you have to start it background and check TIME for not reaching more than TIMEOUT variable.

You can upgrade your check by checking connectivity with remote server (ping).

which operation you are requiring putting TIMEOUT for cp command or after completion of cp command?

hth.
Easy to suggest when don't know about the problem!
Eric Antunes
Honored Contributor

Re: Can I set a timeout to cp?

Hi Muthukumar,

You are right!

I added this:

...

backup_started=0

while [ $exit_code -eq 1 ]
do
if [ $backup_started -eq 0 ]
then
backup_started=1
echo "\nStarting copy..."
cp -Rp $SOURCE_DIR/* $DESTINATION_DIR
exit_code=$?
fi

...

And I'm checking the results...


Best Regards,

Eric Antunes
Each and every day is a good day to learn.
Muthukumar_5
Honored Contributor

Re: Can I set a timeout to cp?

You can try this script.

#!/bin/ksh
WAIT_TIME=5
TIMEOUT=300
TIMER=0

ORIGEM=/disc1/oradata/TST
DESTINO=/_disc2/
exit_code=1
FLAG=0

while [ $exit_code -eq 1 & $FLAG -eq 1 ]
do
echo "waiting for backup...\n"
sleep ${WAIT_TIME}
TIMER=`expr $TIMER + ${WAIT_TIME}`

cp -Rp $ORIGEM/* $DESTINO
exit_code=$?
if [[ $? -eq 0 ]]
then
let FLAG=1
fi

if [ $TIMER -ge $TIMEOUT ]
then
echo "\nWARNING: backup NOT EXECUTED!\n";
exit_code=8;
let FLAG=1
fi
done

echo "\nSUCCESS! Backup executed!!\n"

hth.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: Can I set a timeout to cp?

sorry. Use while loop as,
while [ $exit_code -eq 1 && $FLAG -eq 1 ]

hth.
Easy to suggest when don't know about the problem!
Eric Antunes
Honored Contributor

Re: Can I set a timeout to cp?

The problem is: when the NFS server is up everything runs ok but, when it is down (actual situation), it stops at the cp instruction...

Maybe, starting cp in background mode:

cp -R $SOURCE_DIR/* $DESTINATION_DIR &

But I still need to check if cp ended ok before TIMEOUT!! How can I pass the return code of a command started in background mode??

Thanks,

Eric Antunes
Each and every day is a good day to learn.