I am using a shell script to compile multiple .tex files automatically. But compiling them sequentially takes very long, especially because I need to compile them multiple times for correct output. Here is a short snippet:
#!/bin/bash
for file in *.tex
do
pdflatex ...
done
I tried a solution with xargs
but I was told, that this does not run on macOS. Sadly I did not find a solution that works on all major OS (Windows/ms-dos, macOS, Linux/unix). Can you give me a solution? I only use Linux and can’t test other systems, but it has to work on them.
>Solution :
My immediate though was: Why not use make
? Then you can run all jobs on 8 cores like this:
make -j8
On the other hand, you can just start each process in the background. You won’t have any control about the number of cores to use, though, unless you put in a lot more effort:
#!/bin/bash
for file in *.tex
do
pdflatex ... "$file" &
done