
shell脚本
文章平均质量分 57
XL's妃妃
学习永不止境,用有限的时间做些有意义的事
展开
-
shell笔记
一、什么是shellshell是一个程序,采用c语言编写,是用户和liunx内核沟通的桥梁。它既是一种命令语言,又是一种解释性的编程语言。二、shell中的特殊符号# -n 是指输出不换行[root@localhost ~]# echo -n "date is:";date +%Fdate is:2021-12-17[root@localhost ~]# echo "date is:`date +%F`"date is:2021-12-17[root@localhost ~]#追加重原创 2021-12-20 17:59:53 · 257 阅读 · 0 评论 -
shell脚本学习——实战案例
一、监控一个主机的存活状态方案1[root@localhost AnLi]# sh ping.sh 192.168.3.222192.168.3.222 is up[root@localhost AnLi]# sh ping.sh 192.168.3.223192.168.3.223 is down[root@localhost AnLi]# cat ping.sh#!/bin/bash# ***************************************************原创 2022-02-26 17:30:07 · 918 阅读 · 0 评论 -
shell脚本学习笔记——正则表达式
shell脚本学习笔记——正则表达式一、正则表达式在shell中只有命令grep、sed、awk命令支持正则表达式。二、特殊字符定位符说明^锚定开头^a以a开头 默认锚定一个字符$锚定结尾a$ 以a结尾 默认锚定一个字符测试案例:#精确匹配,以a开头,以c结尾,"^ac$"就是匹配ac[root@localhost shell]# egrep "^ac$" zzbds.shac#模糊匹配[root@localhost shell]# egrep "^a"原创 2022-01-23 20:09:23 · 423 阅读 · 0 评论 -
shell脚本学习笔记——nginx 启动 停止 重启 加载 状态查看
#nginx 启动 停止 重启 加载 状态查看#!/bin/bashnginx_install_doc=/usr/local/nginxproc=nginxnginxd=$nginx_install_doc/sbin/nginxpid_file=$nginx_install_doc/logs/nginx.pidif [ -f /etc/init.d/functions ];then . /etc/init.d/functionselse echo "not found /e原创 2022-01-22 18:49:37 · 362 阅读 · 0 评论 -
shell监控IBM MQ队列深度,10s扫描三次,有两次以上深度值超过5时,则输出队列名称和深度值。
#!/bin/bash #GetMqCurdepth()#{ dismq=`dspmq` status=`echo $dismq | cut -d ' ' -f2 | cut -d '(' -f2 | cut -d ')' -f1` mq_name=`echo $dismq | cut -d '(' -f2 | cut -d ')' -f1` if [ $status = 'Running' ] then echo -e "\033[32m MQ队列管理器$mq_name 运行状态正常原创 2022-01-16 16:53:49 · 1414 阅读 · 0 评论 -
shell脚本学习笔记—循环语句
八、shell流程控制-for循环语句脚本在执行任务的时候,总会遇到需要循环执行的时候,比如说我们需要脚本每个五分钟执行一次ping的操作,除了计划任务,我们还可以使用脚本来完成,那么我们就用到了循环语句。1、for循环介绍很多人把for循环叫做推荐循环,或者for i in 。其实前者说的就是for的特性,for循环的次数和给予的条件是成正比的,你给5个条件,他就循环5次,后者说的是for的语法。循环优点,节省内存;结构更清晰;节省时间成本2、for语法2.1.for语法_onefor原创 2021-12-24 16:28:53 · 877 阅读 · 0 评论