我是靠谱客的博主 懦弱火龙果,这篇文章主要介绍SH脚本实例,现在分享给大家,希望可以做个参考。

请编写一个标准Shell脚本testd,实现如下功能:
A、在Linux操作系统启动的时候,自动加载/mnt/test/test程序。 B、当test异常退出之后,自动重新启动。
C、当test程序重启次数超过100次,自动复位操作系统。 假设你所拥有的资源:
A、目标机器是一台具有标准shell的嵌入式计算机,CPU为ARM7 56MB,内存16MB,软件环境基于Linux2.6.11和BusyBox1.2构建。
B、当前已有11个用户进程在运行,占用了大部分的CPU时间和内存,你可使用的内存只有2MB左右,CPU时间由系统分派。
e.g:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh #load *.so that may need if [ -r /sbin/ldconfig ]; then ldconfig fi #add the libs PATH that may need export LD_LIBRARY_PATH = '/lib' #count the testd run time count = 0 #main loop while [1] do #add excute attribute for mnt/test/test chmod +x /mnt/test/test #run test /mnt/test/test let count = count + 1 echo "test running time is $count" #running time to 100? if ["$count" -eq 100]; then echo "will reboot now" reboot fi #waiting for test stop sleep 3 done

最后

以上就是懦弱火龙果最近收集整理的关于SH脚本实例的全部内容,更多相关SH脚本实例内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(120)

评论列表共有 0 条评论

立即
投稿
返回
顶部