pfcfuse/trainExe.py

16 lines
544 B
Python
Raw Permalink Normal View History

import subprocess
import datetime
# 定义命令
command = "/home/star/anaconda3/envs/pfcfuse/bin/python /home/star/whaiDir/PFCFuse/train.py"
# 获取当前时间并格式化为文件名
current_time = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
output_file = f"/home/star/whaiDir/PFCFuse/logs/log_{current_time}.log"
# 运行命令并将输出重定向到文件
with open(output_file, 'w') as file:
subprocess.run(command.split(), stdout=file, stderr=subprocess.STDOUT)
print(f"Command output has been written to {output_file}")