BASH on Solaris
Hi All,
I posted a problem whereby I was looking to Kill a background (calling Send)mail) process after a certain time had elapsed.
A User Scottn very kindly provided a useful function to do this as below
CheckAndKill()
{
sleep "$EMAIL\_TIMEOUT\_THEN_KILL"
[ "$\(ps | awk '$1 == '$1\)" ] && echo "Killing process $1" && kill -9 "$1"
}
Howvere I am calling this in the wrong way as below:
send_email "Warning Notification" $warning_msg" | tee -a "$LOG_PATH"/email_output.lst &
CheckAndKill $! &
When I check the shell output I can see that I am killing the wrong process ie I am killing the "tee" not the actual send_email function.
The $! passed into CheckAndKill() is clearly picking on the process id of the tee and not the send_email function
Any ideas how to correctly kill the send_email function?
Kind Regards
Satnam