how to kill the process after specific time?
Hi All,
I need to define the specific duration to run a process. i mean after specific time the process should be killed autometically. plese help me to do this. Thanks. |
You need to develop a bit more your question.
In what language you plan to write your application, the process you mentioned ? Or is a regular application in binary format you want to control it ? It is acceptable is this application receives a TERM signal to die or it need to follow some special procedure before that ? Anyway, the simple case is to use kill to send a TERM signal to the application. Code:
#!/bin/bash |
Quote:
Thanks fr your reply. Look i run a script through cron. lets suppose it works for indefinite time. I just want to kill this process automatically after 5 hours. so what should i do? can i specify the time with my script when it runs with cron? or any other way? |
Quote:
Thanks .... I have done this .... see the example ... just wrote a small script runtime=${1:-1m} mypid=$$ cp /Database/Client_db_200802110231.BAK .& cpid=$! sleep $runtime kill -s SIGTERM $cpid echo "Both processes are terminated". I mean now i can define the running time duration of all processes like cp with the time. Cheers. |
I did it in bash a while back. Did it 2 ways; wallclock time and cpu time. Keep in mind that I was doing it as an exercise, so any rough spots are because it worked for me.
here is the wallclock script: Code:
#!/bin/bash Code:
#!/bin/bash |
Quote:
File Edit Options Buffers Tools Insert Help Code:
#!/bin/bash |
All times are GMT -5. The time now is 08:29 AM. |