artesvida
April 10th, 2008, 11:45 PM
I have a bash script that spawns another process, lets it run for a predetermined amount of time, then kills it. I'm logging everything that happens, and I find that I can't redirect the output of the kill command. For example, this line of code:
kill -s SIGTERM $pid >> $LOGFILE
generates nothing in the log file. However, on the terminal where I started the script, I see that the process was killed. I thought maybe I need to redirect STDERR as well as STDOUT, so I changed the line to:
kill -s SIGTERM $pid >> $LOGFILE 2>&1
still nothing in the log. And yes, I still see the output of the kill command on the terminal where I started the script.
Any thoughts? This isn't a big deal, but it's a bit annoying, and I want to be sure that if the "kill" fails that I see it in the log.
Thank you!!!
kill -s SIGTERM $pid >> $LOGFILE
generates nothing in the log file. However, on the terminal where I started the script, I see that the process was killed. I thought maybe I need to redirect STDERR as well as STDOUT, so I changed the line to:
kill -s SIGTERM $pid >> $LOGFILE 2>&1
still nothing in the log. And yes, I still see the output of the kill command on the terminal where I started the script.
Any thoughts? This isn't a big deal, but it's a bit annoying, and I want to be sure that if the "kill" fails that I see it in the log.
Thank you!!!