- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: set a time-limit on child processes?
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-18-2003 08:06 AM
06-18-2003 08:06 AM
set a time-limit on child processes?
I have a shell script that runs a bunch of other scripts ("dumpers"), one after another, collecting their output. In order to scale the process up I'd like to start running a certain number of dumpers simultaneously and would also like to limit the time they have to run.
For example, I'd like to spawn at most X dumpers, then wait for one to complete and spawn another to replace it, proceeding until the entire list of dumpers has been executed, but I need to be able to enforce a time limit to make sure I don't wait indefinitely because of one misbehaving dumper.
The sh-posix man page says the only argument for the wait command is a PID.
If I were doing this in a different language (perl?), my parent process would fork off children and loop continuously, killing children that live too long - is there a way to do something like that in sh?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 08:14 AM
06-18-2003 08:14 AM
Re: set a time-limit on child processes?
The concept you cite can work in a shell too. Launch your children as background processess. As soon as you have, capture their 'pid':
# ./process1 &
# mychild1=$!
# ./process2 &
# mychild2=$!
Now have your parent wait as long as it wants. If a child hasn't finished in time, issue a 'kill ${mychild}' as appropriate.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 08:18 AM
06-18-2003 08:18 AM
Re: set a time-limit on child processes?
That sounds wrong even as I type it, but what am I missing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 08:21 AM
06-18-2003 08:21 AM
Re: set a time-limit on child processes?
Post again, James, and I'll give you a bunny. I didn't realize you never said "wait" until I read the message again after my reply. :-)
Gonna be one of those days...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2003 08:23 AM
06-18-2003 08:23 AM
Re: set a time-limit on child processes?
You can have a loop in the parent that sleeps, periodically wakes up, and interrogates the various child processes running in the background to see if they are alive. A 'kill -o
Regards!
...JRF...