bash日志

#!/bin/bash
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE-$0}")";pwd)
exec 1>>$CUR_DIR"/log/getSpIdBySpUid.log"
exec 2>>$CUR_DIR"/log/getSpIdBySpUid.log.wf"
 . ~/.bashrc

fileName=$1
dateStr=`date +'%Y%m%d'`
current=`date "+%Y-%m-%d %H:%M:%S"`
timeStamp=`date -d "$current" +%s`
#将current转换为时间戳,精确到毫秒
#currentTimeStamp=$((timeStamp*1000+`date "+%N"`/1000000))
dataFile=$CUR_DIR/"spId-"${dateStr}".csv"
while read line
do
    userId=`echo -e $line |awk '{print $1}' `
    if [ "$userId" = "" ]
    then
         continue
    fi
    sql="select F_sp_id from db_vip.t_sp_user_info where F_sp_user_id='${userId}'"
    dataInfo=`echo -e ${sql} |cifdb -t -A`
    echo $dataInfo
    #sp_user_id=`echo -e $test_info |awk '{print $7}' `
    spUserId=`echo -e $dataInfo |awk -F '|' '{print $4}' `
     if [ "$spUserId"  = "" ]
        then
            spUserId=0
     fi
     `echo -e "${spUserId}" >> $dataFile`
done < "./var/${fileName}"

# getSpIdBySpUid.sh
# 日志打到当前文件夹下log目录
# 读当前文件夹下var目录读文件
发布了31 篇原创文章 · 获赞 9 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/sosemseo/article/details/104694671