Script Exection in Background

Below is my process monitor script. if i execute my script in foreground it works fine..but if i run in background it fails. why?

For one thing you should have a 1st line something like:
#! /usr/bin/ksh
we have a faq article that explains why. What does "fails" mean? Tell us precisely what does happen. (Would you email a mechanic, "hey my car doesn't work...what's wrong with it?")

Thanks for your reply.

I used some mailx instead of elm now my script is working in background.

But i still need some help. if i exit my terminal session the script also exits which i dont want to do. Could you please let me know how do i make the script running even though i exit from terminal. Please help gurus.

man nohup (info nohup)
#nohup ./your_script >>/dev/null (or some other place you want logs to be) &

Thanks it works perfect.