- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Specifying command timeout
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
09-13-2004 02:19 AM
09-13-2004 02:19 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2004 02:30 AM
09-13-2004 02:30 AM
Re: Specifying command timeout
we have to the function's in shell in background mode so that main process will be having control on that.
Example:
#!/usr/bin/sh
set -x
fun1()
{
hostname
sleep 20
uname -a
# Normal exit
exit 0
}
sec()
{
ifconfig lan0
echo ok
# Exit
exit 0
}
# Main script
fun1 &
pid=$!
sleep 10
if [[ $(ps -ef | grep -v grep | grep -qw "$pid") -eq 0 ]]
then
kill -9 $pid
fi
# As normal execution; if
# Start second function
sec &
newpid=$!
# check here.
# Script exit
exit 0
fun1 will be expected for 10 minutes. If it is not giving the results then try to make the process stop.
If you want to store the results and error's in a file of the function execution then,
execute as,
fun1 1>/tmp/testlog.out 2>/tmp/testerror.err
HTH.
- Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2004 02:43 AM
09-13-2004 02:43 AM
SolutionThis example script should give you the information you need. Basically you will put the command in the background and check it for every "n" seconds. Kill it after it reaches your limit.
LIMIT=15
COUNT=1
CHECK=2
sleep 20 > /dev/null 2>&1 &
PID=$! #<< PID of the background process
while [ $COUNT -le $LIMIT ]
do
if $(UNIX95= ps -p $PID > /dev/null 2>&1)
then
echo "$PID is still running"
sleep $CHECK
(( COUNT = $COUNT + 1 ))
else
(( COUNT = $LIMIT + 100 ))
kill -0 $PID
break
fi
done
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2004 02:46 AM
09-13-2004 02:46 AM
Re: Specifying command timeout
Elapsed time??
CPU mode time???
Can be done as follows.
start process
speep 15
check if it is there??, if yes kill it.
if not continue
You can use kill -0 "pid" to check if process is active or not.
kill -0 1234
echo $? -->> if zero it is active, else not.
Anil
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2004 04:09 PM
09-13-2004 04:09 PM