Writing a Shell Script with a Time Parameter
Hello there,
I want to write a shell script (preferably a Bourne Shell script) that allows me to fork and run certain number of processes for a given period (t) of time. If you haven't got my point yet, let me explain it briefly. The purpose of my experiment is to compare the performance of two different routing protocols (one is mine and the other is somebody else's) in our wireless Linux-based testbed in terms of their power-efficincy. Hence, the idea is to test the performance with the same VoIP (gphone) application under each routing protocol for a given period of time, while keeping all the other environmental settings the same. I have written a special software that periodically monitors as to how many packets have been sent and received in the whole 6-node testbed and how much energy has been depleted. For this purpose, I need to run each routing protocol, gphone and other processes for "t" hours and then stop them. Can somebody please let me know how this can be performed using a script. I have come up with a follwing script:
pid1 = fork("~/gphone -c 192.168.20.3)
pid2 = fork("../../routing_protocol)
.................................................
pidn = fork("../../monitor_program)
sleep t*60*60*1000 && kill ${pid1} ${pid2} ${pidn}
Do you think that the above script would do the job ?
Thanks in advance for taking your invaluable time to answer my question.
Best Regards,
Siva
|