Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- logpath=/cygdrive/d/RCLogs
- owner="av"
- timeout=600
- tamlog=`ls $logpath | grep -E "^TAM_[0-9]{4}-[0-9]{2}-[0-9]{2}.log$" |
- tail -n 1`
- tgslog=`ls $logpath | grep -E "^TGS_[0-9]{4}-[0-9]{2}-[0-9]{2}.log$" |
- tail -n 1`
- smclog=`ls $logpath | grep -E "^SMC_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]+.log$" | tail -n 1`
- ownerdir=${logpath}/${owner}
- mkdir -p $ownerdir
- tamsrc=${logpath}/${tamlog}
- tgssrc=${logpath}/${tgslog}
- smcsrc=${logpath}/${smclog}
- tamdst=${ownerdir}/tam.log
- tgsdst=${ownerdir}/tgs.log
- smcdst=${ownerdir}/smc.log
- tail -f -n 0 $tamsrc > $tamdst &
- tampid=$!
- tail -f -n 0 $tgssrc > $tgsdst &
- tgspid=$!
- tail -f -n 0 $smcsrc > $smcdst &
- smcpid=$!
- killtails(){
- tampid=$1
- tgspid=$2
- smcpid=$3
- kill -15 $tampid
- kill -15 $tgspid
- kill -15 $smcpid
- }
- trap "echo Keyboard interrupt caught, killing tails; killtails $tampid $tgspid $smcpid; exit 0" 2
- sleep $timeout
- echo Maximum timeout reached, killing tails
- killtails $tampid $tgspid $smcpid
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement