Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I try to start a Mathematica script in the background from the command line, like this:

math -script someFile.m &

then the process gets automatically suspended. Here's a terminal transcript for clarifications:

This happens both on Linux and OS X. Other programs don't typically stop when run in the background.

  • Why does this happen?

  • What can I do to prevent this?

share|improve this question
should this be tagged as bug? – becko Oct 21 '14 at 14:56
up vote 2 down vote accepted

Mathematica for unknown reasons is waiting for input. Possible solution

echo | math -script someFile.m &
share|improve this answer

This is because your shell doesn't allow background processes to print to the console. For instance tcsh has this behavior by default:

% echo "a"&
[1] 26502
[1]  + Suspended (tty output)        echo a
% fg
echo a

In pretty much all shells you should be able to disable this behavior with stty -tostop

% stty -tostop
% echo "a" &
[1] 26539
[1]    Done                          echo a

Re-enable the behavior with stty tostop

You could also redirect the output so it never hits stdout at all:

% echo "a" > /dev/null &
share|improve this answer
My test .m file simply contained a Print. I tested this on Mac with bash and on Linux with tcsh (and later bash). In both cases, the math process gets suspended and doesn't print anything until I resume it with fg. However, all other processes (including echo and python scripts) are able to print stuff to the terminal while in the background. – Szabolcs Oct 19 '13 at 0:56
@Szabolcs Strange, I'm stumped – ssch Oct 19 '13 at 11:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.