Linux使用Shell+crontab定时检查进程,若不存在则运行|守护进程Bash

rclone挂载之后,在rclone盘中做FTP和sharecloud,如果rclone挂掉了会非常麻烦,于是设置了这样一个crontab来守护rclone进程,不罗嗦了上代码:

function check(){

  count=`ps -ef |grep $1 |grep -v "grep" |wc -l`

  if [ 0 == $count ];then

  nohup rclone mount onedrive:/ /storage --allow-other &

  fi

}

check rclone

 


This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/172.html
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy