# Simultaneously running the same .m file with different inputs

I have my Mathematica code in a .m file and I run it from the command line with some parameters. I was wondering, if there is no overlap in input and output files, can I run the same .m file simultaneously with different inputs? Will this create any problems? My code is pretty huge, so I don't want to try that unless I am sure.

I use the following command on the unix/linux commandline:

for i in $var do math -noprompt -script "scriptname.m" "parameter1" "parameter2" done  I would like to run something like: for i in$var
do
math -noprompt -script "scriptname.m" "parameter1" "parameter2" &
done


So that they would run in parallel. Is this possible?

It is possible, and I do it routinely. The limitation is the number of kernels your license allows you to run simultaneously. This I believe is reported by $MaxLicenseProcesses: Of course you need to be careful not to write to the same files etc! It is indeed possible and I use this all the time. Instead of the for ... & done you might want to check out gnu parallel. It's great for running parallel processes from the command line. parallel can be told how many processes to run in parallel, so you don't run out of licences or memory. Here is an example: parallel -j4 "math -noprompt -script scriptname.m parameter1 parameter2" :::$var

Pro tip for windows users: If you install Git (for windows) you get a working native unix-like environment based on msys (including bash and perl). By copying the parallel script (written in perl) to GITINSTALLDIR\bin everything just works.