https://github.com/selboo/cronshell
cronshell
多台服务器相同 crontab
只执行一次
cronshell 安装
# go build
cronshell 配置
# cat /etc/cronshell.conf
[Log]
logfile=/var/log/cronshell.log
[Redis]
host=192.168.15.100
port=6379
- logfile 日志路径
- host redis 地址
- port redis 端口
crontab 配置
服务器 Server A01
# cat /etc/cron.d/cronshell
MAILTO=""
SHELL=/bin/cronshell
PATH=/sbin:/bin:/usr/sbin:/usr/bin
* * * * * root d=$(date); echo $d run ok >> /tmp/t.log
查看执行结果
# cat /tmp/t.log
Sat May 30 22:47:01 CST 2020 run ok
Sat May 30 22:48:01 CST 2020 run ok
Sat May 30 22:51:01 CST 2020 run ok
Sat May 30 22:54:01 CST 2020 run ok
服务器 Server B01
# cat /etc/cron.d/cronshell
MAILTO=""
SHELL=/bin/cronshell
PATH=/sbin:/bin:/usr/sbin:/usr/bin
* * * * * root d=$(date); echo $d run ok >> /tmp/t.log
查看执行结果
# cat /tmp/t.log
Sat May 30 22:49:01 CST 2020 run ok
Sat May 30 22:50:01 CST 2020 run ok
Sat May 30 22:52:01 CST 2020 run ok
Sat May 30 22:53:01 CST 2020 run ok
Sat May 30 22:55:01 CST 2020 run ok
Sat May 30 22:56:01 CST 2020 run ok
转载请注明:爱开源 » cronshell 多台服务器相同 crontab 只执行一次