如何实时查看数据信息呢,方式多的去了,但是还是脚本最为方便。
#!/bin/bash # 用户名 MYSQL_USER=root # 密码 MYSQL_PWD=123456 # 库名 MYSQL_NAME=center # 主机 MYSQL_HOST=172.0.0.1 # 端口号 MYSQL_PORT=3306 mysql -u${MYSQL_USER} -p${MYSQL_PWD} -P${MYSQL_PORT} -h${MYSQL_HOST} -D${MYSQL_NAME} << EOF > $2 set character_set_client = utf8; set character_set_results = utf8; set character_set_connection = utf8; $1 EOF
$! $2 就是命令后面加的参数
sh export.sh 'select id,name from sport;' './export.txt'
https://developers.dingtalk.com/document/app/custom-robot-access
#!/bin/bash MYSQL_USER=root MYSQL_PWD=123456 MYSQL_NAME=center MYSQL_HOST=172.0.0.1 MYSQL_PORT=3306 SQL_DATA=`mysql -u${MYSQL_USER} -p${MYSQL_PWD} -P${MYSQL_PORT} -h${MYSQL_HOST} -D${MYSQL_NAME} << EOF set character_set_client = utf8; set character_set_results = utf8; set character_set_connection = utf8; select id,name from sport; EOF` echo $SQL_DATA DATA="$(date +'%Y-%m-%d %T') $SQL_DATA" MSG='{"msgtype": "text", "text": { "content": "hello world chy '$DATA'" } }' echo $MSG curl 'https://oapi.dingtalk.com/robot/send?access_token=abc' \ -H 'Content-Type: application/json' \ -d "$MSG
crontab -e
编辑新增(linux最小单位是分钟,如下表示1分钟执行一次)
*/1 * * * * sh /usr/local/shell/dingding.sh
perfect!!!