文章插图
同步本机时间ntpdate 210.72.145.44
清除系统缓存,空出更多内存free && sync && echo 3 > /proc/sys/vm/drop_caches && free
杀掉僵尸进程kill $(ps -A -ostat,ppid | awk '/[zZ]/ && !a[$2]++ {print $2}')
显示全部arp解析tcpdump 'arp' -e -i eth0 -n -p -t |grep is-ateth0对应要换成你的显步名称
监看本机网卡端口情况tcpdump -n -vv tcp port $1 -i em1em1为对应的网卡名称 。
检查本机连接数netstat -nat |awk '{print $6}'|sort|uniq -c|sort -nr
查看Tomcat日志中的异常tail -F
/var/log/tomcat8/catalina.out |grep -E 'Exception|at' |grep -v WARN这里tomcat8要对应成你的相应版本
删除5天以前的tomcat日志sudo find /var/lib/tomcat8/logs/ -mtime +5 -exec rm {} ;
清空 memcache 缓存以下存成脚本,
#!/bin/sh#实现通过主机名,端口清相应的memcache缓存 if(($#<2));thenecho "usage:$0 host port";exit 1;fi#如果参数缺失,退出程序,返回状态1exec 6<>/dev/tcp/$1/$2 2>/dev/null;#打开host的port 可读写的socket连接,与文件描述符6连接if(($?!=0));thenecho "open $1 $2 error!";exit 1;fi#如果打开失败,$?返回不为0,终止程序echo -e "flush_all">&6;echo -e "quit">&6;#将HEAD 信息,发送给socket连接cat<&6;#从socket读取返回信息,显示为标准输出exec 6<&-;exec 6>&-;#关闭socket的输入,输出exit 0;
修改VirtualBox虚拟机的内存分配保存脚本,第一个参数为虚拟机的名称,第二个为内存大小,如2G#!/bin/bashVM=$1VBoxManage controlvm $VM poweroffVBoxManage modifyvm $VM--memory $2VBoxManage startvm $VM --type headless
为VirtualBox 虚拟机加磁盘#!/bin/sh#machine=phptestmachine=$1VBoxManage controlvm "$machine" poweroffdisk=/home/xwx/VirtualBox VMs/$machine/${machine}_swap.vdi#VBoxManage createhd --filename "$disk" --size 1024#VBoxManage storageattach "$machine" --storagectl "IDE" --port 1 --type hdd --medium $disk#VBoxManage storageattach "$machine" --storagectl SATA --port 1 --type hdd --medium $diskVBoxManage storageattach "$machine" --storagectl "SATA 控制器" --port 1 --type hdd --medium "$disk"
修改克隆虚拟机的ip地址虚拟机克隆之前,第一次启动时需要修改ip才能远程控制:#!/bin/bash# set modifyip=/etc/network/interfaceshn=/etc/hostnamenetmask=255.255.255.0network=192.168.20.0broadcast=192.168.20.255gateway=192.168.20.1# mod ip、mask、gw、DNS、hostnamecp $ip /etc/network/interfaces.baksed -ri 's/(iface eth0 inet).*/iface eth0 inet static/' /etc/network/interfacesecho "Please input IP:"read ipaddif [ -n "$ipadd" ]; thenecho "address $ipadd" >> $ipecho "Modify Completed "elseecho "Not Modified"fiecho "netmask $netmask" >> $ipecho "Netmask Modify Completed "echo "network $network" >> $ipecho "Network Modify Completed "echo "broadcast $broadcast" >> $ipecho "Broadcast Modify Completed "echo "gateway $gateway" >> $ipecho "Gateway Modify Completed "echo "Please input hostname:"read hostnameif [ -n "$hostname" ]; thenecho "$hostname" > $hnecho "Modify Completed "elseecho "Default Hostname"fiecho "All modification completion"read -n1 -p "Whether restart network [Y/N]?"case $REPLY inY|y) echo/etc/init.d/networking restart;;N|n) echoecho "Network needs to restart to take effect!!!!!!";;esacexit
实时统计Nginx日志使用goaccess软件,可能用apt install goaccess或yum install goaccess安装 。sudo goaccess /var/log/nginx/access.log --log-format='%h %^[%d:%t %^] "%r" %s %b "%R" "%u" "-" "%v"' --date-format='%d/%b/%Y' --time-format='%H:%M:%S'
备份nginx配置文件nginx会频繁修改,改之前最好备份一下:
##########################################################################MySQLdump####################################################!/bin/sh# -----------------------------# the directory for story your backup file.backup_dir="/home/your/backup"# date format for backup file (dd-mm-yyyy)time="$(date +"%Y%m%d")"MKDIR="$(which mkdir)"RM="$(which rm)"MV="$(which mv)"TAR="$(which tar)"GZIP="$(which gzip)"#针对不同系统,如果环境变量都有 。可以去掉# check the directory for store backup is writeabletest ! -w $backup_dir && echo "Error: $backup_dir is un-writeable." && exit 0# the directory for story the newest backuptest ! -d "$backup_dir" && $MKDIR "$backup_dir"$TAR -zcPf $backup_dir/$HOSTNAME.nginx.$time.tar.gz/etc/nginx$TAR -zcPf $backup_dir/$HOSTNAME.cron_daily.$time.tar.gz/etc/cron.daily#delete the oldest backup 30 days agofind $backup_dir -name "*.gz" -mtime +30 |xargs rm -rfexit 0;
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 茶园常用农药有哪些,加强茶园冬管
- kali linux 系统黑客全部武器库安装教程
- linux中netstat和ss命令详解
- 科学管理Linux系统中的组与组成员
- 三分钟告诉你如何监控 Linux 服务器状态?
- 钻进 Linux 内核看个究竟
- Linux 中 RPM 的构建与打包
- Linux 5.7内核新特性介绍
- 分享几款免费的连接Linux的使用工具
- linux服务器上创建mysql5.7定时任务,实现自动发布文章