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
itsmrbeltre
  • 412
  • 7
  • 18

1 Answers1

1

Goal: to capture the output of a particular terminal command when a job is launched using sbatch

Current working solution:

  1. Create a python function that does the task that you want to execute
  2. Call the function inside the bash file
  3. Generate output file

Example:

#!/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
Matthias Beaupère
  • 1,731
  • 2
  • 17
  • 44
itsmrbeltre
  • 412
  • 7
  • 18