Shell脚本查看网卡实时流量
#!/bin/bash while [ "1" ] do eth=$1 RXpre=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $2}') TXpre=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $10}') sleep 1 RXnext=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $2}') TXnext=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $10}') clear echo -e "t RX `date +%k:%M:%S` TX" RX=$((${RXnext}-${RXpre})) TX=$((${TXnext}-${TXpre})) if [[ $RX -lt 1024 ]];then RX="${RX}B/s" elif [[ $RX -gt 1048576 ]];then RX=$(echo $RX | awk '{print $1/1048576 "MB/s"}') else RX=$(echo $RX | awk '{print $1/1024 "KB/s"}') fi if [[ $TX -lt 1024 ]];then TX="${TX}B/s" elif [[ $TX -gt 1048576 ]];then TX=$(echo $TX | awk '{print $1/1048576 "MB/s"}') else TX=$(echo $TX | awk '{print $1/1024 "KB/s"}') fi echo -e "$eth t $RX $TX " done
调用方式:
./traff.sh eth1 或 bash traff.sh eth1
可以实时显示网卡流量大小:
Shell脚本实现上传zip压缩文件到FTP服务器
#/bin/bash#creator:lihuibin#date:2014-03-1016:45#desc:uploadfiletoftphosts="192.168.56.100"port=21user=testpass=testpwdwork_path="/var/www/cms"packname="publish"#hosts=$1#port=$2#user=$3#pass=$4#packn
CentOS下mysql定时备份Shell脚本分享
1、备份语句#/usr/local/mysql/bin/mysqldump-utest-ptesttest--socket=/tmp/mysql.3306.sock/usr/local/mysql_backup/3306/test-`date+%Y%m%d`.sql.gz语句说明:/usr/local/mysql/bin/mysqldump:MySql
Linux Shell的一些使用小技巧收集
检查远程端口是否对bash开放:echo/dev/tcp/8.8.8.8/53&&echo"open"让进程转入后台:Ctrl+z将进程转到前台:fg产生随机的十六进制数,其中n是字符数:opensslrand-he