我有 31 个名为 runner1.sh..runner31.sh 的 shell 脚本。我需要创建一个 cron 作业并将所有这些 .sh 脚本按顺序运行,条件是如果它们尚未运行,则它们必须运行,同时如果 runnerX 失败,它应该停止并且不开始运行 runnerX+1。
我编写了一个用于聚合这些任务的 shell 脚本,如下所示,但我不确定这是否是正确的解决方案:
ps -ef |grep -i grep | grep runner1.sh && echo "not to start" && sh runner1.sh && sh runner2.sh && sh runner3.sh && sh runner4.sh && sh runner5.sh && sh runner6.sh && sh runner7.sh && sh runner8.sh && sh runner9.sh && sh runner10.sh && sh runner11.sh && sh runner12.sh && sh runner13.sh && sh runner14.sh && sh runner15.sh && sh runner16.sh && sh runner17.sh && sh runner18.sh && sh runner19.sh && sh runner20.sh && sh runner21.sh && sh runner22.sh && sh runner23.sh && sh runner24.sh && sh runner25.sh && sh runner26.sh && sh runner27.sh && sh runner28.sh && sh runner29.sh && sh runner30.sh && sh runner31.sh
请告诉我这种方法是否正确或解决方案是别的。