Wednesday, October 29, 2008

Shell script to monitor processes

Many a time, one is faced with a situation where one needs to monitor a process to its completion. For example, if one is performing a clone, one has to copy the source files to the target or if one is performing a backup of any instance, the cp or tar commands that one has fired has to be monitored to its completion.

I generally use a customised script (as below) during those situations to monitor the processes.


while true
do
ps -fu <owner_of_the_process> grep <cp or rman or process_id> wc -l
printf "\n\nPress Ctrl+C to exit this loop.......\n\n"
sleep <the_number_of_seconds_this_process_should_sleep>
done


No comments: