1

I want to be able to run a command inside the bash file and save it in somefile.txt

I am running my script the following way:

  • sbatch file.sh and inside this file I have a terminal command
4

1 回答 1

1

目标:在使用 sbatch 启动作业时捕获特定终端命令的输出

当前工作解决方案:

  1. 创建一个执行您要执行的任务的python函数
  2. 调用 bash 文件中的函数
  3. 生成输出文件

例子:

#!/bin/bash

#SBATCH --job-name application1
#SBATCH --partition=TSA
#SBATCH --nodelist=node52

module load openmpi/1.10.2/gcc/4.9.3

mpirun  -np 1  NASA.IS

# I have placed the python call at the end because I want to capture 
# the time it took for the application to run and save it to a file
# I was able to code everything inside the python file and generate the
# corresponding data

python outputCollector.py
于 2016-09-09T23:13:54.833 回答