随笔分类 -  shell 脚本

摘要:root@ localhost ~]# vim rsyncd.sh #!/bin/bash cat >/etc/rsyncd.conf<<EOF #全局配置 uid = root gid = root use chroot = no max connections = 200 timeout = 3 阅读全文
posted @ 2020-02-14 16:28 Databasess 阅读(174) 评论(0) 推荐(1)
摘要:1.手动安装一下zabbix rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm yum -y install zabbix zabbix-web-mysql zab 阅读全文
posted @ 2020-02-12 14:48 Databasess 阅读(614) 评论(0) 推荐(0)
摘要:#!/bin/bash for i in `seq 1 3` do c8080=`expr 8080 + $i` cd /opt if [ ! -d "/opt/tomcat/tomcat$i/apache-tomcat-8.5.35/webapps/solo" ];then cp solo.war 阅读全文
posted @ 2020-02-04 14:24 Databasess 阅读(134) 评论(0) 推荐(0)
摘要:#!/bin/bash yum -y install mariadb mariadb-server systemctl stop firewalld setenforce 0 cat /etc/my.cnf|grep server-id if [ $? -ne 0 ];then sed -i '10 阅读全文
posted @ 2020-01-31 14:47 Databasess 阅读(349) 评论(0) 推荐(0)
摘要:#!/bin/bash systemctl stop firewalld setenforce 0 setenforce 0 yum -y install epel-release yum -y install supervisor touch /etc/supervisord.d/tomcat.i 阅读全文
posted @ 2020-01-16 20:58 Databasess 阅读(153) 评论(0) 推荐(0)
摘要:#!/bin/bash yum -y install keepalived > /dev/null touch /opt/kill.sh cat >/opt/kill.sh<<EOF #!/bin/bash systemctl stop keepalived EOF same=`grep -f /o 阅读全文
posted @ 2020-01-16 20:57 Databasess 阅读(260) 评论(0) 推荐(0)
摘要:#!/bin/bashyum -y install keepalived >/dev/nulltouch /opt/kill.shcat >/opt/kill.sh<<EOF#!/bin/bashsystemctl stop keepalivedEOFsame=`grep -f /opt/keepa 阅读全文
posted @ 2020-01-16 20:54 Databasess 阅读(178) 评论(0) 推荐(0)
摘要:#!/bin/bash java -version > /dev/null if [ $? -ne 0 ];then rpm -ivh jdk-8u131-linux-x64_.rpm tar -zxvf apache-tomcat-8.5.35.tar.gz netstat -ntlp |grep 阅读全文
posted @ 2020-01-08 17:11 Databasess 阅读(283) 评论(0) 推荐(0)
摘要:#!/bin/bash for i in `ls|egrep sh$` //用到egrep 正则匹配结尾为sh的 do mv $i `echo $i|cut -d. -f1`.txt //提取除了.sh前面的部分 字符串拼接.txt done 阅读全文
posted @ 2020-01-08 09:06 Databasess 阅读(311) 评论(0) 推荐(0)
摘要:#!/bin/bash tar -zcv -f log-$(date +%F).tar.gz /var/log 阅读全文
posted @ 2020-01-06 21:09 Databasess 阅读(290) 评论(0) 推荐(0)
摘要:判断网址是否可用 #!/bin/bash . /etc/init.d/functions check_fun(){ url_list=(www.baidu.com www.tudou.com www.youku.com www.xxx222.com) for i in ${url_list[@]} 阅读全文
posted @ 2020-01-06 09:16 Databasess 阅读(624) 评论(0) 推荐(0)
摘要:了解到几种加密密码的方式 myPassword用你想用的密码字符串代替 1.有OpenSSL的话,可以使用openssl命令: openssl passwd -crypt myPassword 2、如果用Apache Web服务器,那么也可以用htpasswd htpasswd -nd user 用 阅读全文
posted @ 2020-01-05 21:19 Databasess 阅读(498) 评论(0) 推荐(1)
摘要:expect ftp 交互 yum -y install expect vim ftp_upload.sh #!/usr/bin/expect spawn ftp localhost expect "Name*" send "ftp\n" expect "ftp>*" send "cd pub/ot 阅读全文
posted @ 2020-01-04 15:26 Databasess 阅读(179) 评论(0) 推荐(0)
摘要:1.定时执行格式 crontab时间格式说明 minute(分)可以设置0-59分 hour(小时)可以设置0-23小时 day of month(日期)可以设置1-31号 month(月份):可以设置1-12月 1.1 每一个小时执行一次 * 1/* * * * 1.2 每一天的三点 00 03 阅读全文
posted @ 2019-12-23 16:06 Databasess 阅读(460) 评论(0) 推荐(0)
摘要:1.ssh交互 #!/bin/bash passwd='123' usradd="172.168.74.138" /usr/bin/expect <<EOF spawn ssh root@$usradd expect { "yes/no" { send "yes\r";exp_continue } 阅读全文
posted @ 2019-12-23 15:18 Databasess 阅读(333) 评论(0) 推荐(0)
摘要:1.自动检测mysql主从 有没有配置成功 #!/bin/bash check(){ list=($(mysql -e "show slave status\G;" 2>/dev/null |egrep "Running|Behind" |head -n3|awk -F ':' '{print $2 阅读全文
posted @ 2019-12-23 15:15 Databasess 阅读(205) 评论(0) 推荐(0)
摘要:猜数字 #! /bin/bash prive=$(($RANDOM%100+1)) echo $prive count=1 while true do read -p "请输入一个1--100的随机数:" num if [ $num -gt $prive ]; then echo "大了" elif 阅读全文
posted @ 2019-12-23 15:10 Databasess 阅读(249) 评论(0) 推荐(0)
摘要:#!/bin/bashnginx=/usr/local/nginx/sbin/nginx #把nginx的启动定义成变量 方便被调用check(){ #check 检查 测试nginx是否启动 输出nginx的启动或关闭 netstat -ntlp |grep nginx if [ $? -eq 0 阅读全文
posted @ 2019-12-07 10:09 Databasess 阅读(311) 评论(0) 推荐(0)
摘要:示意图: 代码展示 [root@ localhost ~]# vim nginx.sh #!/bin/bash service iptables stop setenforce 0 netstat -ntlp |grep nginx if [ $? -eq 0 ];then echo "nginx安 阅读全文
posted @ 2019-12-05 20:10 Databasess 阅读(496) 评论(0) 推荐(0)