微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

bash脚本执行从上次失败的地方

谁能告诉我如何写一个脚本来执行从上次停止的地方。 我的bash脚本包含24个顺序执行的脚本文件。 但是,如果任何一个脚本失败,下次当我执行脚本文件,我不希望脚本从script1开始,而应该从上次失败的地方开始。 请指教。

如何使用粘贴(1)排列列? 或者如何使一个alignment的表在shell中合并行?

简单的PowerShell脚本来重新启动networking适配器变得不够简单,使工作在受限制的用户帐户

我在Windows上使用Python。 运行后如何删除脚本?

使用bash来读取一个文件,然后从提取的单词中执行一个命令

使用一些Unix命令将每个备用行放在一列中

一个粗略的方法

#!/bin/bash # Needs bash 4 or later,for `;&` to work [ "$1" = "--frest_start" ] && rm statusfile touch statusfile read status < statusfile [ "$status" = "" ] && status=0 case $status in 0) ./script1; echo 1 > statusfile ;& 1) ./script2; echo 2 > statusfile ;& 2) ./script3; echo 3 > statusfile ;& # ....... & so on till 23) ./script24; echo 24 > statusfile ;; esac

但是通过Makefile来做,似乎也是一个很好的解决方案。

.NOTParaLLEL .PHONY: all frest_start all: make step1 make step2 make step3 .... make step24 step%: script% "./$<" touch "$@" frest_start: rm steP* make all

#mail.sh function errortest { "$@" local status=$? if [ $status -ne 0 ]; then echo "error with $1" >&2 fi return $status } errortest sh /home/user1/test1.sh errortest sh /home/user1/test2.sh

每当脚本发生任何错误时,都会在terminal.i上出现错误

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐