当前位置: 首页 > news >正文

Shell篇之编写apache启动脚本

Shell篇之编写apache启动脚本

1. 脚本编写

vim apache_ctl.sh
#!/bin/bashfunction_start(){printf "Starting Apaache  ...\n"/opt/lanmp/httpd/bin/apachectl start
}function_stop(){printf "Stoping Apaache  ...\n"/opt/lanmp/httpd/bin/apachectl stop
}function_restart(){printf "restarting Apaache  ...\n"/opt/lanmp/httpd/bin/apachectl restart
}function_status(){apache_stat=0apache_tmpa=`ps -ef | grep http | grep root | grep -v grep | awk '{print $2}'`apache_tmpb=`cat /opt/lanmp/httpd/logs/httpd.pid`if [ `lsof -i:10068 | wc -l` -gt 0 ]; thenif [ `ps -ef | grep httpd | grep -v grep | wc -l` -gt 0 ]; thenif [[ $apache_tmpa -eq $apache_tmpb ]]; thenapache_stat=1fifi
fiif [ $apache_stat -eq 1 ]; thenecho "apache(pid $apache_tmpa) is runing!"
elif [ $apache_stat -eq 0 ]; thenecho "apache is not runing!"
fi
}if [ "$1" = "start" ]; thenfunction_start
elif [ "$1" = "stop" ]; thenfunction_stop
elif [ "$1" = "restart" ]; thenfunction_restart
elif [ "$1" = "status" ]; thenfunction_status 
elseprintf "Usage: automate {start|stop|restart|status} \n"
fi

2. 赋权

chmod +x apache_ctl.sh

3. 命令

./apache_ctl.sh start
./apache_ctl.sh status
./apache_ctl.sh restart 
http://www.lryc.cn/news/442823.html

相关文章:

  • 头条|司法部公法局局长访谈:推进高水平公立鉴定机构建设!加快推进司法鉴定立法!
  • 高密原型验证系统解决方案(上篇)
  • 新产品,推出 MLX90372GVS 第三代 Triaxis® 位置传感器 IC,适用于汽车和工业系统(MLX90372GVS-ACE-308)
  • JAVA毕业设计178—基于Java+Springboot+vue的智能家具管理系统(源代码+数据库+万字论文)
  • 掌握 Python 异步上下文管理器
  • 当你问AI“有点烦”
  • 音视频入门基础:AAC专题(3)——AAC的ADTS格式简介
  • 高可用web集群面经:集群搭建、nginx+keepalived高可用、prometheus+zabbix监控、nfs+dns
  • vue3+ts+supermap iclient3d for cesium功能集合
  • 【案例71】配置https之后 IE打不开登陆页面 Uclient没有问题
  • ROS 设置dhcp option 6 多个地址格式
  • Python 二级考试
  • Linux笔记---简单指令
  • 软考无损连接判断
  • 微服务-- Sentinel的使用
  • TS React 项目中使用TypeScript
  • 【JavaEE】IP协议 应用层协议
  • CRM如何助力科技服务机构突破业务瓶颈?
  • 牛啊,GitHub 代理加速图文教程
  • 基于扣子(Coze)打造第一个智能体——个性化对话机器人
  • 算法-深度拷贝链表(138)
  • 【Kubernetes】常见面试题汇总(十四)
  • 灵当CRM系统index.php存在SQL注入漏洞
  • 详解QT元对象系统用法
  • 【Python】从基础到进阶(八):文件操作与上下文管理
  • c#:System.Text.Json 的使用四(如何忽略[JsonPropertyName])
  • 【CPU】CPU的物理核、逻辑核、超线程判断及L1、L2、L3缓存、CacheLine和CPU的TBL说明
  • NET WPF使用组件库HandyControl
  • 计算机毕业设计之:教学平台微信小程序(
  • VMware Fusion虚拟机Mac版 安装Win10系统教程