@@ -14,6 +14,25 @@ if [ "$port" == "" ]; then
fi
```
+#### 检测指定服务是否正常运行
+
+新建文件写入以下内容
+```
+#!/usr/bin/env bash
+read name
+pgrep $name > /dev/null
+if [ $? -gt 0 ];then
+ echo "`date` $name is stop" >> ~/mysql_listen.log
+ systemctl $name mysql
+else
+ echo "`date` $name running" >> ~/mysql_listen.log
+fi
+给脚本添加执行权限后运行,输入服务名称即可
设置定时任务
@@ -321,3 +321,11 @@ bg 1 #将任务编号为 1 调到后台运行
fg 1 #将任务编号为 1 调到前台运行
+#### pgrep 命令
+pgrep nginx # 查看 nginx 进程
+pgrep -l nginx #查看 nginx 进程名称