- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- 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-06-2005 09:09 PM
06-06-2005 09:09 PM
Re: Can I set a timeout to cp?
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 10:07 PM
06-06-2005 10:07 PM
Re: Can I set a timeout to cp?
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 10:25 PM
06-06-2005 10:25 PM
Re: Can I set a timeout to cp?
#!/bin/ksh
WAIT_TIME=5
TIMEOUT=300
TIMER=0
ORIGEM=/disc1/oradata/TST
DESTINO=/
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 10:28 PM
06-06-2005 10:28 PM
Re: Can I set a timeout to cp?
while [ $exit_code -eq 1 && $FLAG -eq 1 ]
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 11:57 PM
06-06-2005 11:57 PM
Re: Can I set a timeout to cp?
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 12:13 AM
06-07-2005 12:13 AM
Re: Can I set a timeout to cp?
cp -R $SOURCE_DIR/* $DESTINATION_DIR > /disc2/.../cp.log
2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 04:31 AM
06-07-2005 04:31 AM
Re: Can I set a timeout to cp?
> down(actual situation), it stops at the cp instruction.
that's exactly why you need to first ping the nfs server && then kick-off the copy.
ping
The purpose here is that the entire command line works or fails as a unit. Only iff the ping succeeds does the copy kickoff and if the ping fails the copy never gets executed.
see script attached...
enjoy!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 08:49 AM
06-07-2005 08:49 AM
Re: Can I set a timeout to cp?
If this were me I would do something like this:
df -F nfs /desiredmountpoint
If that returns a zero status then you can assume that NFS is available. Of course, you need a timeout mechanism for this as well.
This would be my approach:
TDIR=${TMPDIR:-/var/tmp}
timeoutcmd.pl -t 20 "df -F nfs /desiredmountpoint" > /dev/null 2>/dev/null
STAT=${?}
if [[ ${STAT} -eq 0 ]] # df ok
then
timeoutcmd.pl -t 5400 "cp -p file1 file2 /desiredmountpoint" > /dev/null 2>/dev/null
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Cp failed; status ${STAT}" >&2
fi
else
echo "NFS unavailable; status ${STAT}" >&2
fi
exit ${STAT}
Note: This is not the same Perl script posted earlier:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 09:59 PM
06-07-2005 09:59 PM
Re: Can I set a timeout to cp?
I'm testing your perl script now. Is there any good manual about perl?
Hi Sandman,
The problem is that the command "ping
Best Regards,
Eric Antunes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 11:29 PM
06-07-2005 11:29 PM
Re: Can I set a timeout to cp?
With the NFS server down I get "NFS unavailable; status 127".
With the NFS server up, I still get "NFS unavailable; status 127"...
Thanks,
Eric Antunes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 11:31 PM
06-07-2005 11:31 PM
Re: Can I set a timeout to cp?
From the command line, I get:
interpreter "/usr/bin/perl" not found
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 11:34 PM
06-07-2005 11:34 PM
Re: Can I set a timeout to cp?
find / -name "perl"
which perl
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 11:35 PM
06-07-2005 11:35 PM
Re: Can I set a timeout to cp?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 11:40 PM
06-07-2005 11:40 PM
Re: Can I set a timeout to cp?
ping
ping
if [[ $? -eq 0 ]]
then
action;
else
echo 'server failed'
fi
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 11:42 PM
06-07-2005 11:42 PM
Re: Can I set a timeout to cp?
"NFS unavailable; status 255"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 11:42 PM
06-07-2005 11:42 PM
Re: Can I set a timeout to cp?
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 11:51 PM
06-07-2005 11:51 PM
Re: Can I set a timeout to cp?
Did you modify clay's script?
Are you using this?
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Cp failed; status ${STAT}" >&2
else
echo "NFS unavailable; status ${STAT}" >&2
fi
exit ${STAT}
please post that script to help you out.
Before testing any script try it command line with single commands.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2005 12:09 AM
06-08-2005 12:09 AM
Re: Can I set a timeout to cp?
WAIT_TIME=30
TIMEOUT=540
TIMER=0
SOURCE_DIR=/disc2/app/oravis/admin/TST/bdump/
DESTINATION_DIR=/NFS_SERVER_disc2/bdump_PROD
TEMP_DIR=${TMPDIR:-/var/tmp}
timeoutcp_clay2.pl -t 20 "df -F nfs ${DESTINATION_DIR}" > /dev/null 2>/dev/null
STAT=${?}
if [[ ${STAT} -eq 0 ]] # df ok
then
timeoutcp_clay2.pl -t 540 "cp ${SOURCE_DIR}* ${DESTINATION_DIR}" > /dev/
null 2>/dev/null
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Cp failed; status ${STAT}" >&2
else
echo "Cp completed; status ${STAT}" >&2
fi
else
echo "NFS unavailable; status ${STAT}" >&2
fi
exit ${STAT}
And I found why. Executing the following from the command line:
$export DESTINATION_DIR=/hp440_disc2/bdump_PROD
$x=timeoutcp_clay2.pl -t 20 "df -F nfs ${DESTINATION_DIR}" > /dev/null 2>/dev/null; echo $x
I get nothing (null) into x...
Thanks,
Eric Antunes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2005 12:10 AM
06-08-2005 12:10 AM
Re: Can I set a timeout to cp?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2005 12:17 AM
06-08-2005 12:17 AM
Re: Can I set a timeout to cp?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2005 12:52 AM
06-08-2005 12:52 AM
Re: Can I set a timeout to cp?
#!/bin/ksh
WAIT_TIME=30
TIMEOUT=540
TIMER=0
SOURCE_DIR=/disc2/app/oravis/admin/TST/bdump/
DESTINATION_DIR=/NFS_SERVER_disc2/bdump_PROD
TEMP_DIR=${TMPDIR:-/var/tmp}
if [[ -f ./timeoutcp_clay2.pl ]]
then
echo "Script is available"
else
echo "exiting"
exit 1
fi
./timeoutcp_clay2.pl -t 20 "df -F nfs ${DESTINATION_DIR}" > /dev/null 2>/dev/null
STAT=${?}
if [[ ${STAT} -eq 0 ]] # df ok
then
./timeoutcp_clay2.pl -t 540 "cp ${SOURCE_DIR}* ${DESTINATION_DIR}" > /dev/null 2>/dev/null
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "Cp failed; status ${STAT}" >&2
else
echo "Cp completed; status ${STAT}" >&2
fi
else
echo "NFS unavailable; status ${STAT}" >&2
fi
exit ${STAT}
#
Put ./timeoutcp_clay2.pl in the current path with this script. It will work.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2005 12:54 AM
06-08-2005 12:54 AM
Re: Can I set a timeout to cp?
ping
will return 0 or 1 code based upon hostname machine up.
#!/bin/ksh
echo "Enter remote machine name to check"
read host
ping $host -n 1 1>/dev/null 2>&1
if [[ $? -eq 0 ]]
then
echo "$host is running"
else
echo "$host is down"
fi
#################
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2005 03:24 AM
06-08-2005 03:24 AM
Re: Can I set a timeout to cp?
Perl can be found on the Applications CD's or dowmloaded from www.perl.org/CPAN. In either case it's an easy swinstall.
-------------------------------------------
However, there was a bug in the the timeoutcmd.pl script. Unlike the C equivalent pclose() function, Perl's close() function returns 0 on a failure. I needed to reverse the login and also take care of the case where the exit status of a command was exactly divisible by 256 because exit() only returns the low-order 8 bits.
This version should do exactly what you want.
NOTE: the data is send to stdout so if you did a command ls "ls -l /etc" using timeoutcmd.pl, the ls is sent to stdout.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2005 11:48 PM
06-08-2005 11:48 PM
Re: Can I set a timeout to cp?
It seems to be working now with perl 5.x!
With the NFS server down, I get:
"Script is available
sh[55]: 11128 Alarm call
NFS unavailable; status 142"
With the NFS server up, I get:
"Script is available
Cp completed; status 0"
Many thanks,
Eric Antunes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 04:29 AM
06-09-2005 04:29 AM
Re: Can I set a timeout to cp?
Here's the improved version with the close() function returning the correct logic and ensuring that the low-order 8 bits reurned by exit() will be 0 if okay and non-zero otherwise.
- « Previous
-
- 1
- 2
- Next »