1

I'm trying to write a script that does

x =$ncore
numactrl -C $x ( time -p $exe ) > out.txt 2>&1

on the terminal ( time $ exe ) > out.txt 2>&1 worked as i wanted to (out.txt containing output of time and executable )

i'm using red hat 6.2 and time is not GNU version( i'm assuming from the fact that -a -o options don't work)

i want out.txt to have output from the executable and at the end have output from the time command.

the bash script is giving me problems with having ( so i used ( time -p $exe ) and now numactl sees ( as the executable.

is there a way to use numactl and time command together and have the output i want ?

1 Answer 1

2

If numactrl wants a command, but you want to use some shell features, just give it the shell as a command:

numactrl -C $x bash -c "( time -p $exe ) > out.txt 2>&1"

When you runtime -p $exe from a bash prompt or within a bash -c, you're using the bash builtin version of time. The one with the -o option is an external command, so to use it from bash you have to specify command time or /bin/time or /usr/bin/time.

If you run numactrl -C $x time ... then it probably runs the external command, so -o should work in that case, but if not then you always have the bash -c method.

Note that the output format is different between the various versions of time. The GNU coreutils version prints more information than the bash builtin version.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.