博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Shell之导出数据库的表为Excel的脚本
阅读量:4026 次
发布时间:2019-05-24

本文共 1319 字,大约阅读时间需要 4 分钟。

## exportLog.sh

#!/bin/bash#*/30 * * * * /usr/donica/script/exportLog.shAIRPLANE="Default"TMP1="cmt_operate_"YEAR=$(date +%Y)MONTH=$(date +%m)DAY=$(date +%d)TMP2=".xls"FILENAME=${TMP1}${YEAR}${MONTH}${DAY}${TMP2}FILENAME_MONTH=${TMP1}${YEAR}${MONTH}${TMP2}#echo $FILENAMELAST_DAY=`cal $MONTH $YEAR|xargs echo|awk '{print $NF}'`FILENAME_30="cmt_operate_30days.xls"MYSQL_PATH='/opt/lampp/bin/mysql'FLAG='--user=hhwifi --password=donica2012 --database=cmt_wifi'OPERATE_PATH='/root/'#delete the files every timefind /usr/tuyue/log -mtime +30 -name "cmt_operate_*" -exec rm -f {} \;$MYSQL_PATH $FLAG -e "select * from cmt_operate where UNIX_TIMESTAMP( operate_time ) >= UNIX_TIMESTAMP( ) - 60*60*24*30" > $FILENAME_30$MYSQL_PATH $FLAG -e "select * from cmt_operate where DATE_FORMAT( operate_time,  '%Y-%m-%d' ) = DATE_FORMAT( NOW() , '%Y-%m-%d')" > $FILENAME##Get Plane ID Begin##PLANE_STR=$($MYSQL_PATH $FLAG -e "select var_value from cmt_config where var_name='system_id' limit 1")AIRPLANE_STR=$(echo $PLANE_STR | awk '{print $2}')if [ -z "$AIRPLANE_STR" ]; then        echo ">>>>>>>>[cmt_wifi/cmt_config/system_id] is NULL,please set the flight id for it."else        AIRPLANE=$AIRPLANE_STRfimkdir -p /usr/tuyue/log/$AIRPLANE##Get Plane ID End##\cp -f /root/cmt_operate_* /usr/tuyue/log/$AIRPLANE/rm /root/cmt_operate_*~

转载地址:http://fbvbi.baihongyu.com/

你可能感兴趣的文章
网页设计里的浮动 属性
查看>>
Maximum Subsequence Sum
查看>>
PTA:一元多项式的加乘运算
查看>>
CCF 分蛋糕
查看>>
解决python2.7中UnicodeEncodeError
查看>>
小谈python 输出
查看>>
Django objects.all()、objects.get()与objects.filter()之间的区别介绍
查看>>
python:如何将excel文件转化成CSV格式
查看>>
Django 的Error: [Errno 10013]错误
查看>>
机器学习实战之决策树(一)
查看>>
[LeetCode By Python] 2 Add Two Number
查看>>
python 中的 if __name__=='__main__' 作用
查看>>
机器学习实战之决策树二
查看>>
[LeetCode By Python]7 Reverse Integer
查看>>
[LeetCode By Python]9. Palindrome Number
查看>>
[leetCode By Python] 14. Longest Common Prefix
查看>>
[LeetCode By Python]107. Binary Tree Level Order Traversal II
查看>>
[LeetCode By Python]108. Convert Sorted Array to Binary Search Tree
查看>>
[leetCode By Python]111. Minimum Depth of Binary Tree
查看>>
[LeetCode By Python]118. Pascal's Triangle
查看>>