Killing a process if it is not using any cpu time

Hi i am a newbie thanks in advance

i have a process which keeps on running but doesn't use any CPU time and doesn't do the functionality which it is suppose to do .

If i kill the process and start the process again then the process kicks in and starts using CPU time and continues to do its work , but after sometime it goes to the idle state again.

Don't know y it is doing this. But if i can get a command or a line which will check for the cpu usage of this process and kill it if its idle then my problem will be solved .

Please help me in this.

just because it's not using cpu time, doesn't always mean it's not functioning. most long running processes do have periods of inactivity, depending on what it truly does. if possible, describe further what this command is programmed to perform, and is there some log file or query status command to really determine if the process is functioning normally?

Good answer.

More importantly - this sounds like a code problem. It sounds like the program state becomes hosed and the process deadlocks. This is based on your assumption that this process is always supposed to be 'doing something'.

If that is the case, fix the process code. What OS? I intend to show you how to use /proc to see what is going on.... unless I need plan B

This process is suppose to poll for files and process those files , this process goes to idle state even if files are present to be processed.
If it is a code problem how will i confirm there is a deadlock due to some code problem.

OS details: Linux 2008 x86_64 x86_64 x86_64 GNU/Linux