how to check whether a script is running actively or hanged/ in deadlock)

Hi
I have a doubt regarding process states in HP unix system. Is there a way to check whether a process is hanged or still actively running? I have few scripts which run for a long time. but sometimes these are getting hanged. But i'm never sure whether they are running or waiting in kind of deadlock. these process are present when i check using "ps -ef" command.
Is there any way to tail the output of a process that has already started? i've asked this because we can know whether it's hanged or running.

You can run the script with set -x or with ksh -x options and redirect the stderr to some file. This will echo each statement into that file when it is run. Then you can check that file and know exactly what exactly your script is doing.

another tool on HPUX is "truss"...

truss -p activePROCid
or
truss initiatingJOB

Thanks blowtorch. I tried as u have said. It is working when i'm executing from the command prompt. But when the cronjob runs this process, where will it output the text to if we don't specify any outpath ? I've given the option set -x at the beginning of file without any path for o/p file.

When you run a script with 'set -x' options, it is run in debug mode, where each command is printed in the terminal window before it is executed. When a script runs through cron, there are no terminals involved, so you wouldn't get any output unless you redirect the stderr to some file.