|
@@ -1,14 +1,27 @@
|
|
|
import subprocess
|
|
|
+from datetime import datetime
|
|
|
|
|
|
-
|
|
|
-result = subprocess.run(['./script1.sh'], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
|
-
|
|
|
-
|
|
|
-if result.returncode == 0:
|
|
|
- print("script1.sh 执行成功")
|
|
|
-
|
|
|
- result2 = subprocess.run(['./script2.sh'], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
|
- print("script2.sh 执行成功")
|
|
|
-else:
|
|
|
- print("script1.sh 执行失败")
|
|
|
- print(f"错误输出: {result.stderr}")
|
|
|
+
|
|
|
+now = datetime.now()
|
|
|
+date_str = now.strftime("%Y-%m-%d")
|
|
|
+
|
|
|
+
|
|
|
+log_file = f"script_output_{date_str}.log"
|
|
|
+
|
|
|
+
|
|
|
+script1_path = "./script1.sh"
|
|
|
+script2_path = "./script1.sh"
|
|
|
+
|
|
|
+with open(log_file, 'w') as f:
|
|
|
+
|
|
|
+ result = subprocess.run([script1_path], shell=True, stdout=f, stderr=subprocess.STDOUT)
|
|
|
+
|
|
|
+
|
|
|
+ if result.returncode == 0:
|
|
|
+ print("script1.sh 执行成功")
|
|
|
+
|
|
|
+ result2 = subprocess.run([script2_path], shell=True, stdout=f, stderr=subprocess.STDOUT)
|
|
|
+ print("script2.sh 执行成功")
|
|
|
+ else:
|
|
|
+ print("script1.sh 执行失败")
|
|
|
+ print(f"错误输出: {result.stderr}")
|