bash

Summary

  • 在我们写完一个 shell 的时候,往往需要我们调试一下,查看一下具体的执行过程。
  • 使用 bash -x /opt/xxx.sh 来查看它的执行过程。

Demo

[root@fss-rule microservices]# bash -x /opt/microservices/check.sh /opt/microservices/aliyun aliyun-message-0.1-all.jar

+ log_file=restart_sh.log
++ ps -ef
++ wc -l
++ grep aliyun-message-0.1-all.jar
+ be_running=3
+ echo 3
3
+ echo /opt/microservices/aliyun
/opt/microservices/aliyun
+ echo aliyun-message-0.1-all.jar
aliyun-message-0.1-all.jar
+ '[' 3 -eq 0 ']'
+ tee -a restart_sh.log
++ TIMESTAMP
+++ date '+%Y-%m-%d %H:%M:%S'
++ echo 2020-04-22 10:42:41
+ echo '2020-04-22 10:42:41 aliyun-message-0.1-all.jar is running, no need to restart'
2020-04-22 10:42:41 aliyun-message-0.1-all.jar is running, no need to restart
原文地址:https://www.cnblogs.com/duchaoqun/p/12758452.html