I have some bots, which are run by the System scheduler at given time interval. But sometimes due to some logical error I have to stop these bots manually. How can I find these processes run by the scheduler and kill them?
|
|
You can kill processes by name. For example, on Linux, *BSD and Solaris, If you want to specifically target processes started by the scheduler, and you're killing the processes manually, you can run If you want to be able to kill these processes automatically in a homemade method, make them store their process ID in a file. This kind of file is called a pidfile when it's used to only have a single instance of the process running (which may or may not be something you want). If you want multiple instances, store the PIDs in separate files in a common directory; here's a shell snippet that does this:
A better solution, if you have hard criteria to detect runaway processes, is to use a general monitoring program, or in simple cases just put a limit on how long the process is allowed to run. You may find these links helpful:
|
|||
|
|
|
I'd suggest popping their PID ($$) into a file after you spawn them. You can then use this to kill the process. |
|||
|
|
|
A basic try/catch branch in most programming languages to find infinite loops or other cases of errors should work. Possibly an inactive/unresponsive timer on the processes to watch for hangs. |
|||
|
|