1#!/bin/bash 2# Copyright (c) 2021 Huawei Device Co., Ltd. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15set -e 16 17IFS=$'\n' 18read_log_file="/data/acm_read_xts" 19max_ts=0 20pid=$(ps -ef | grep 'acm_read' | grep -v grep | cut -F 2) 21if [ ! "${pid}x" == "x" ];then 22 killall acm_read 23fi 24acm_read & 25cat /dev/null > $read_log_file 26while true 27do 28 lines=$(cat $read_log_file) 29 cat /dev/null > $read_log_file 30 for line in $lines 31 do 32 ts=$(echo $line | grep 'XTSCHECK' | cut -F 2 | cut -d ',' -f 1) 33 if [ `echo "$ts > $max_ts" | bc` -eq 1 ];then 34 max_ts=$ts 35 data=$(echo $line | grep 'XTSCHECK' | cut -F 4 | cut -d '[|]' -f 2) 36 echo "[`date +%s.%N`]" $data 37 acm_write $data 38 fi 39 done 40 sleep 0.1 41done