当前位置:网站首页>Shell script fails to execute repeatedly automatically
Shell script fails to execute repeatedly automatically
2022-07-26 10:50:00 【aLLLiyyy】
Before we pass terminal And linux When the system interacts , Some commands are often used . However, some commands are time-consuming , For example, I want to give an example of the synchronous download command . We can't wait for hours by the computer to wait for the command to finish and then carry out some operations . What's more hateful , The command may fail to execute , At this time, it needs to be re executed . We need a result that can receive the last command , Then do the corresponding treatment according to the results , For example, restart the command and so on .
The code is as follows
#!/bin/bash
repo sync
echo "======sync starting======"
while(($? == 1))
do
sleep 3
du -sh >> abc.txt
echo "======sync failed,re sync starting====="
repo sync
done
This code begins #! /bin/bash The interpreter that executes for the specified script , Which one shell The interpreter executes this shell Script .
repo sync For downloading scripts , If he makes a mistake , that $? Just read 1, So enter a cycle ,
du -sh >> abc.txt This code is to write the total capacity data of the current folder to abc.txt This document should be established in advance .
And then execute it again repo sync Until he ends the order normally .
边栏推荐
- Happens-Before原则深入解读
- Koin
- The problem of formatting IAR sprintf floating point to 0.0 in UCOS assembly
- shell 脚本 失败自动重复执行
- 用两个栈实现队列
- 1748.唯一元素的和
- BigDecimal's addition, subtraction, multiplication and division, size comparison, rounding up and down, and BigDecimal's set accumulation, judge whether BigDecimal has decimal
- Codepoint 58880 not found in font, aborting. flutter build apk时报错
- MySQL速学-2021-09-01
- Sword finger offer (43): left rotation string
猜你喜欢

PLC与伺服电机连接

在神州IV开发板上为STemWin 5.22加入触屏驱动
![[leetcode daily question 2021/5/8]1723. The shortest time to complete all work](/img/e7/a48bb5b8a86cbc4cd5b37bb16661a8.png)
[leetcode daily question 2021/5/8]1723. The shortest time to complete all work

Capture ZABBIX performance monitoring chart with selenium

Bash shell学习笔记(三)

Sql Server 数据库之数据类型

RT thread learning notes (V) -- edit, download and debug programs

RT-Thread 学习笔记(一)---配置RT-Thread开发环境
![Error[pe147]: declaration is incompatible with 'error problem](/img/4f/57145d78f4dc1fe84d2f271dd9d82f.png)
Error[pe147]: declaration is incompatible with 'error problem

mysql20210906
随机推荐
@JsonFormat和@DateTimeFormat的区别和使用
104.二叉树的最大深度
mysql20210906
如何组装一个注册中心?
[leetcode daily question 2021/8/31] 1109. Flight reservation statistics [medium] differential array
扫雷pro版2021-08-19
[machine learning notes] [style transfer] deeplearning ai course4 4th week programming(tensorflow2)
shell 脚本 失败自动重复执行
剑指Offer(四十四):翻转单词顺序序列
During the interview, how did the interviewer evaluate the level of rust engineers?
Bash shell学习笔记(七)
@Validated 和 @Valid 的真正区别和使用方式
flutter 背景变灰效果,如何透明度,灰色蒙板遮罩
按二进制数中1的个数分类
在altium designer中禁用USBJATG
232.用栈实现队列
创建EOS账户 Action
@The difference and use of jsonformat and @datetimeformat
2021-08-12 function recursion_ Learn C language with brother Peng
1837.K进制表示下的各位数字总和