How to Run Mathematica Script in Terminal


Using math -run or wolfram -run we could execute a Mathematica script through ssh in terminal.

A Mathematica script that can be run though ssh should be pure script like a .m file of Mathematica.

To run it, the following command is used.

math -run "<<my-mathematica-script.m"


math -run < my-mathematica-script.m

After math executes the script, it falls back to the REPL interface. If this is not useful at all, we apply -noprompt.

math -run -noprompt "<<my-mathematica-script.m"

Combined with nohup and screen we can run a Mathematica script in the background.

nohup math -run "<<my-mathematica-script.m" &> my-mathematica-script.out&

Published: by ;

Lei Ma (2017). 'How to Run Mathematica Script in Terminal', Datumorphism, 05 April. Available at:

Table of Contents

Current Ref:

  • til/programming/