- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Can I set a timeout to cp?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2005 08:34 PM
06-02-2005 08:34 PM
So is it possible to set a 90 minutes timeout for cp for example?
Thanks,
Eric Antunes
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2005 08:47 PM
06-02-2005 08:47 PM
Re: Can I set a timeout to cp?
In you script after the database shutdown and when you issue the cp command you chekc for the retun code.
Whne the retun code is not zero it. not successfull then define the following and have the sleep wait_time in a loop.
Eg:-
WAIT_TIME=30
TIMEOUT=900
TIMER=0
Check with the return code of the cp command and then have the following in a loop.
while [ $retruncode -eq 1 ]
do
echo "Waiting for the database copy..."
sleep ${WAIT_TIME}
TIMER=`expr $TIMER + ${WAIT_TIME}`
if [ $TIMER -ge $TIMEOUT ] ; then
echo "\nWARNING: Timeout while waiting for copying to complete.\n"
RC=8
fi
done
IA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2005 08:51 PM
06-02-2005 08:51 PM
Re: Can I set a timeout to cp?
If you want to make timeout to cp process then,
execute cp operation in a process with background mode. Get the PID and sleep for 90 minutues and check PID is completed or not. If not kill that.
Example:
shutdown() {
..
}
copy() {
rcp backupserver:/tmp/test/*.db /database/
}
start(){
...
}
shutdown
copy &
PID=$!
start
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2005 08:54 PM
06-02-2005 08:54 PM
Re: Can I set a timeout to cp?
shutdown
copy &
PID=$!
sleep 90860
kill -9 $PID 2>/dev/null
start
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2005 08:59 PM
06-02-2005 08:59 PM
Re: Can I set a timeout to cp?
that means even if the cp is successful, you still have to wait 90 minutes!
You'd want to sleep for 1 minute and check the PID. Put the sleep/check in a loop that executes 90 times, unless the PID disappears in which case it would break/stop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2005 09:03 PM
06-02-2005 09:03 PM
Re: Can I set a timeout to cp?
Basic concept is we have to make cp operation in background and control that with it's PID. We can add points like getting return code from cp and ps -ef | grep -v grep | grep -q $PID return code to make sleep 90 minutes operation.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2005 09:42 PM
06-02-2005 09:42 PM
Re: Can I set a timeout to cp?
I'm analysing the proposed solutions to assign points more correctly after.
Thanks,
Eric Antunes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2005 12:19 AM
06-03-2005 12:19 AM
Re: Can I set a timeout to cp?
WAIT_TIME=30
TIMEOUT=300
TIMER=0
SOURCE_DIR=/disc1/patches
DESTINATION_DIR=/
cp -R $SOURCE_DIR/* $DESTINATION_DIR
while [ $exit_code -eq 1]
do
sleep ${WAIT_TIME}
TIMER=`expr $TIMER + ${WAIT_TIME}`
if [$TIMER ge $TIMEOUT]; then
echo "\WARNING: ...!\n"
exit_code=8
fi
But I get:
"Syntax error at line 49 : `do' is not matched.". I'm missing something with the "while do" cicle...?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2005 12:21 AM
06-03-2005 12:21 AM
Re: Can I set a timeout to cp?
done
if .. fi
do .. done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2005 12:57 AM
06-03-2005 12:57 AM
Re: Can I set a timeout to cp?
you may also wish to add the "-p" switch when doing the cp -R...
-p will cause cp to preserve in the copy as many of the modification time, access time, file mode, user ID, and group ID as allowed by permissions.
hope this helps too!
regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2005 03:13 AM
06-03-2005 03:13 AM
Re: Can I set a timeout to cp?
Now I get:
"A ] character is missing"
Any clue??
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2005 03:23 AM
06-03-2005 03:23 AM
Re: Can I set a timeout to cp?
Now depending upon the size of the data to be copied you can also put a wait time for cp to comlpete. If it does not, kill cp and start database.
One catch here is to take into consideration the load on system/network load that will impact the copy time. And hence copy wait time needs to be adjusted.
To address this you can have another script/check in same script to keep comparing the source data and copied data.
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2005 04:02 AM
06-03-2005 04:02 AM
Re: Can I set a timeout to cp?
Seems an excelent idea. With "ping -vr
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2005 04:03 AM
06-03-2005 04:03 AM
Solution1) Shutdown database
2) Create a vxfs snapshot of all your Oracle filesystems -- this will take only seconds
3) Restart your database
4) NFS exportfs your vxfs snapshots (read-only)
5) NFS Mount (read only) your snapshots on the client
6) Do the copies
7) NFS unmount the snapshots on the client
8) exports -i -u /yoursnapshot(s)
9) umount the snapshots
And yes, vxfs snapshot filesystems can be exported.
This will give you almost all the uptime of a hot backup with all the security of a cold backup. And in fact, now that time is of no consequence, you could backup to tape instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2005 06:07 AM
06-03-2005 06:07 AM
Re: Can I set a timeout to cp?
Use it like this:
timeoutcp.pl -t 5400 file1 file2 file3 /mydestdir/xxx/
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Cp failed; status ${STAT}" >&2
fi
Invoke as timeoutcp.pl -u for usage; it does a cp -p but you can alter the system() call to do whatever you like.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2005 07:37 AM
06-04-2005 07:37 AM
Re: Can I set a timeout to cp?
made modifications to the test script so that it first pings the NFS server && if it's up kicks off the copy. Taking this approach the script aborts when either the cp succeeds or the timeout value is exceeded.
============================================
wait_time=30
timeout=300
timer=0
srcdir=/disc1/patches
destdir=/
while true
do
ping
RC=$?
let timer=$timer + $wait_time
if [[ $RC -eq 0 || $timer -ge $timeout ]]
then
echo "\WARNING: ...!\n"
break
fi
sleep $wait_time
done
============================================
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2005 05:45 AM
06-05-2005 05:45 AM
Re: Can I set a timeout to cp?
>Now I get:
> "A ] character is missing"
you need to put a space between the "1" an "]"
while [ $exit_code -eq 1 ]
hth
bv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2005 05:59 AM
06-05-2005 05:59 AM
Re: Can I set a timeout to cp?
bv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2005 08:36 PM
06-05-2005 08:36 PM
Re: Can I set a timeout to cp?
Clay,
I'm very interested in your snapshots solution but how can I do it?
"Create a vxfs snapshot of all your Oracle filesystems -- this will take only seconds" -> How can I do this??
Also thanks for your perl script. I'll try to understand it to see what is the better script for me...
Bob,
I've assigned point to your 2º login, thanks because that error is solved.
Now, I get another:
"sh[54]: test: Specify a parameter with this command."
Sandman,
I'll also analyse you script and assign you points accordingly.
Best Regards,
Eric Antun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2005 09:16 PM
06-05-2005 09:16 PM
Re: Can I set a timeout to cp?
if [$TIMER ge $TIMEOUT]; then
then you need spaces wither side of the [ and ] and ge should be -ge etc
so it should read
if [ "$TIMER" -ge "$TIMEOUT" ] ; then
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 02:53 AM
06-06-2005 02:53 AM
Re: Can I set a timeout to cp?
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 03:12 AM
06-06-2005 03:12 AM
Re: Can I set a timeout to cp?
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 03:35 AM
06-06-2005 03:35 AM
Re: Can I set a timeout to cp?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 07:40 AM
06-06-2005 07:40 AM
Re: Can I set a timeout to cp?
>
> exit_code = 1
> while [ $exit_code -eq 1 ]
>
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 08:47 PM
06-06-2005 08:47 PM
Re: Can I set a timeout to cp?
I did it with the following script:
WAIT_TIME=30
TIMEOUT=300
TIMER=0
ORIGEM=/disc1/oradata/TST
DESTINO=/
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