in reply to Start a service, wait 10 seconds, and stop the service.
Blasphemy time ... why not just write a shell command instead of a Perl script for this? For example, here is what i use to restart our mod_perl enable web server for Krang:
Use the right tool for the right job. :)/usr/local/krang/bin/krang_ctl stop sleep 2 /usr/local/krang/bin/krang_ctl start
UPDATE: oh uh ... i see now that i got your order backwards ... start, wait, then stop. I'd still be tempted to solve this with a shell script rather than Perl, because you are dealing mostly with shell commands. One naive solution would be to grep for the process, but i'm sure there is a better way to capture the PID and stop it. Perhaps if you wrote some wrapper script like the apachectl script that keeps track of its PID. It writes the PID to a file and reads that file when you need to stop it. You could write the wrapper in Perl and have it accept two args: start and stop -- then use a shell script to call the Perl script.
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Start a service, wait 10 seconds, and stop the service.
by tphyahoo (Vicar) on Jun 17, 2005 at 16:07 UTC | |
by cool_jr256 (Acolyte) on Jun 17, 2005 at 16:15 UTC |