编程语言中都有条件判断,shell编程也不例外,下面我们来看一下shell中应该怎么使用if条件判断 以下蓝色字体部分为Linux命令,红色字体的内容为输出的内容: # cd /opt/scripts # vim script07.sh 开始编写script07.sh的脚本,脚本内容为: #! /bin/sh if [ 3 -gt 2 ] then echo "3>2" fi if [ 3 -lt 2 ] then echo "3<2" else ech
linux shell编程,先等10秒再判断是否有进程存在,存在就再等10秒再杀了进程才运行 crontab每分钟执行一次,但5秒以上才有更新数据,有时候一分钟可能跑不完上一个进程,需要先等10秒再判断是否有进程存在,存在就再等10秒再杀了进程(有没有在都执行杀进程的命令)才运行,超过20秒没有执行完成就判断为假死异常了,需要删掉再继续运行.这样各种情况都考虑到了. #!/bin/sh PID=`ps aux | grep lstm_prob.py | awk '{print $2}'` if
原文链接: Shell编程 打算有时间简单了解shell编程 1.shell结构 一个简单的例子: [root@localhost shell]# vi example #!/bin/sh #This is show what a example looks like. echo "my first shell example." echo # this inserts an empty line in output. echo "We are current in the