shell script redirect output
Posted
by
Andy
on Stack Overflow
See other posts from Stack Overflow
or by Andy
Published on 2014-06-10T03:31:53Z
Indexed on
2014/06/10
15:24 UTC
Read the original article
Hit count: 402
I have a shell script to monitor process due to preventing the process closed. If the process is closed, that script will restart it. BTW, when the system starts, the crontab will run the script automatically. How can I get the output of the process which started by the shell script?
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
while :
do
if [ -z "$(ps -ef | grep -v grep | grep 225.0.6.4)" ]; then
date +"%m-%d-%y %T" >> /home/andy/log/stream.log
echo "225.0.6.4 - 103 not worked and restart process" >> /home/andy/log/stream.log
echo "225.0.6.4 - 103 not worked and restart process"
/usr/bin/tzap -a 1 -c /home/andy/channels.conf -o - -r -p "D" | /home/andy/ffmpeg -f mpegts -i pipe:0 -c:v libx264 -preset medium -crf 23 -bufsize 3000K -minrate 1200k -maxrate 1200k -pix_fmt yuv420p -g 50 -s 1024x768 -acodec libmp3lame -b:a 128k -ac 2 -ar 44100 -f mpegts udp://225.0.6.4:50000 &
fi
sleep 1
done
© Stack Overflow or respective owner