shell
weixin_45171153
这个作者很懒,什么都没留下…
展开
-
进程检查py
import psutil import os def checkprocess(processname): pl = psutil.pids() for pid in pl: if psutil.Process(pid).name() == processname: return pid if isinstance(checkprocess(“wps.exe”), int): print(“进程存在”) print(os.popen(‘tasklist’)) os.system(‘taskkill /IM原创 2020-09-02 17:52:03 · 79 阅读 · 0 评论 -
shell文件保留
#!/bin/bash #保留文件数 res=5 dir=/data/wwwroot/cpu/ date=$(date “+%Y%m%d-%H%M%S”) num=$(ls -l $dir|grep ^- |wc -l) while(( $num> res))doOldFile=res)) do OldFile=res))doOldFile=(ls -rt dir∣head−1)file=dir| head -1) file=dir∣head−1)file=(ls -rt $dir|原创 2020-09-02 17:44:47 · 123 阅读 · 0 评论 -
服务器检查
服务器检查 #!/bin/bash #redis检查 red=ps -aux |grep redis|grep -v grep|wc -l if (( $red > 0 ));then echo “redis正常” else curl '钉钉API' \ -H 'Content-Type: application/json' \ -d '{"msgtype": "text", "text": { "content": "redis挂掉了" } }' fi #nginx检查 nginx=ps -aux|原创 2020-09-02 17:32:25 · 160 阅读 · 0 评论