supervise安装与使用

确认当前是否已经安装
which supervise
/usr/local/bin/supervise


软件下载安装
-----------------------------------------------------------------------------------------------------------------------------------------
http://cr.yp.to/daemontools/install.html
wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz

tar -xvf daemontools-0.76.tar.gz
cd admin/daemontools-0.76


vim src/conf-cc
gcc -O2 -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings -include /usr/include/errno.h

package/install

# which supervise
/usr/local/bin/supervise


命令执行
-----------------------------------------------------------------------------------------------------------------------------------------
cd /opt/scripts/
ls
mkdir test
cd test/

vim edate.sh
#! /bin/bash
echo `date +"%Y-%m-%d %H:%M:%S"`
sleep 5
vim run
#! /bin/sh
echo "start test /opt/scripts/test"
sh /opt/scripts/test/edate.sh

  

chmod +x run
cd ..
chown -R mysql.mysql test/

然后以mysql用户执行以下命令
nohup supervise test/ > /tmp/test_date.log &


$ ps -ef |grep sup
root 1219 1 0 Jul26 ? 00:00:00 /usr/local/bin/supervise /usr/local/addops/wonder-agent
mysql 5046 32154 0 11:07 pts/0 00:00:00 supervise test/

脚本输出
start test /opt/scripts/test
2019-09-30 11:09:23
start test /opt/scripts/test
2019-09-30 11:09:29
start test /opt/scripts/test
2019-09-30 11:09:34
start test /opt/scripts/test
2019-09-30 11:09:39
start test /opt/scripts/test
2019-09-30 11:09:44
start test /opt/scripts/test
2019-09-30 11:09:49
start test /opt/scripts/test
2019-09-30 11:09:54
start test /opt/scripts/test

 

posted @ 2019-09-30 11:52  方诚  阅读(2877)  评论(0编辑  收藏  举报