1、shell脚本,fi后输入Enter键,不然会出错误,若在windows下编写shell脚本,上传到Linux后,vi 文件名,输入 :set ff?, 若为dos,则需要修改为Linux格式,:set ff=unix 然后输入:wq!保存退出。

#!/bin/sh
count=`ps -ef |grep /usr/local/jobmail/Study/TomasSendNew2.py |grep -v "grep" |wc -l`
echo $count
if [ 0 == $count ];then
nohup python2.7 /usr/local/jobmail/Study/TomasSendNew2.py > /usr/local/jobmail/Study/TomasSendNew2.log 2>&1 &
echo $count
fi

若TomasSendNew2.py正常运行,则count=1,若挂掉,则count=0,这时就需要重启。
2、crontab 定时运行shell脚本
定时触发.sh
crontab -e 写入0 */3 * * * /usr/local/jobmail/Study/restartSend.sh,代表每隔三分钟运行.sh
crontab -l 可查看crontab文件。

GitHub 加速计划 / li / linux-dash
13
2
下载
A beautiful web dashboard for Linux
最近提交(Master分支:3 个月前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐