我正在创建一个脚本,可以从git存储库中获取一些内容。
但首先我想将SIGUSR1发送到我在机器上运行的多个节点,并且一旦所有进程停止,我将继续进行git pull
所以基本上我会跑
killall -s SIGUSR1 node
因为我的节点正在进行无限循环,我想拦截这个信号并在循环的一部分中杀死,我知道它不会影响任何数据。
因此,当所有节点都停止时,我将继续
但是如何在执行git pull并再次启动节点循环之前等待所有节点进程干净地退出
来自man killall
:
-w, --wait
Wait for all killed processes to die. killall checks once per second if any of the
killed processes still exist and only returns if none are left. Note that killall may
wait forever if the signal was ignored, had no effect, or if the process stays in zombie
state.