- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ksh script - echo to screen even though app is not...
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
Discussions
Discussions
Forums
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
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
тАО03-09-2009 06:39 PM
тАО03-09-2009 06:39 PM
And writes to screen.
But the first command, takes about 2 minutes to run, and the script goes on to the next two commands.
I want it to wait until the first command to finish before it goes on to the next, and echo it to the screen.
#!/bin/ksh -p
# Stop the application commands:
echo Disabling xxx application...
/opt/app/application/shutdown
(here is where I want it to wait, or maybe output # every 10 seconds...)
echo xxx application -- disabled
echo
echo Disabling yyy application...
/opt/app/application2/stopapp
echo yyy application -- disabled
echo
Solved! Go to Solution.
- Tags:
- background
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 07:01 PM
тАО03-09-2009 07:01 PM
Re: ksh script - echo to screen even though app is not done
/opt/app/application/shutdown
Maybe this fires off some background shutdowns and return to you before it is complete.
One method would be to loop and monitor for the processes that are shutting down. Check every 10 seconds and echo the "#" then exit the loop once the processes are gone.
good luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 08:54 PM
тАО03-09-2009 08:54 PM
Re: ksh script - echo to screen even though app is not done
As per your script every thing are looks ok. Check your ├в /opt/app/application/shutdown├в script
if your /opt/app/application/shutdown script is having any & which means run the job in background and execute the next line.
So check your /opt/app/application/shutdown script and delete the &
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 09:37 PM
тАО03-09-2009 09:37 PM
Re: ksh script - echo to screen even though app is not done
The shutdown script may separately end these processes and removing the "&" will make the script wait for each single process to end before stopping the next process. This could seriously slow the whole process.
A loop in the monitoring script would definitely be better in this case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 01:09 AM
тАО03-10-2009 01:09 AM
Re: ksh script - echo to screen even though app is not done
while :
do
kill -0 $pid 2>/dev/null||break
sleep 1
done
kill -0 fails if the process doesn't exist anymore
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 03:49 PM
тАО03-10-2009 03:49 PM
Re: ksh script - echo to screen even though app is not done
Has this helped? How about some points?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 04:45 PM
тАО03-10-2009 04:45 PM
Re: ksh script - echo to screen even though app is not done
while
do
ps -ef|grep app
echo #
done
But I dont know the syntax....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 04:54 PM
тАО03-10-2009 04:54 PM
Solution> I was looking at possibly...
> while
> do
> ps -ef|grep app
> echo #
> done
while true
do
PID=$(UNIX95= ps -C app -o pid=)
echo "I see ${PID}"
done
Note the whitespace after UNIX95= . This keeps the setting only for the duration of the command line so that it only applies to the 'ps'. The 'pid=' argument says to suppress a header line and just report the process (if any) whose basename matches "app". This is the truly safe way to find a process by name in HP-UX.
Regards!
...JRF...
- Tags:
- UNIX95
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2009 04:18 AM
тАО03-11-2009 04:18 AM
Re: ksh script - echo to screen even though app is not done
Try this following :
PID=`/opt/app/application/shutdown &`
wait $PID
At this step you script will wait until detached process shudown ends.
Good luck,
Roland