我有一个定期失败的进程,有时会启动重复的实例..
当我运行:
ps x |grep -v grep |grep -c "processname"
我会得到:
2
这是正常的,因为进程运行恢复过程..
如果我得到了,
0
我会想要启动这个过程:
4
我会想要停止并重新启动该过程
我需要的是一种取得结果的方法 ps x |grep -v grep |grep -c "processname"
然后设置一个简单的3选项功能
ps x |grep -v grep |grep -c "processname"
if answer = 0 (start process & write NOK & Time to log /var/processlog/check)
if answer = 2 (Do nothing & write OK & time to log /var/processlog/check)
if answer = 4 (stot & restart the process & write NOK & Time to log …Run Code Online (Sandbox Code Playgroud) 我在脚本中使用下面的
add-apt-repository ppa:webupd8team/java
行当从脚本运行时,我得到一个提示,按[return]确认将源添加到存储库
我可以自动退货吗?
其次,我正在安装oracle-java7-installer,并且有一个许可协议,提示用户:1 ..确定许可协议2 ..选择YES接受许可条款
我可以自动执行OK并自动键盘左键和OK以接受许可条款吗?此脚本用于本地测试,我希望每次脚本都暂停这些用户输入.
我已经看到这种方法为命令管道YES:
yes | <command here>
我希望有一个类似的方法来自动化这些步骤......
我有一个脚本安装了几个应用程序,要求用户在脚本期间输入约5次Y. 是否可以自动化或绕过Y,以便脚本只需运行而无需任何用户交互?