Error

Error while running Matlab code on Ubuntu command line (with -nojvm option)

matlab -nodisplay -nojvm -r '3*4, exit'

MATLAB is exiting because of fatal error

Killed

Problem: exit command is called before Matlab has fully started

Solution 1: avoid option -nojvm if you don't need

Solution 2: add a short break (1 second) before exit

matlab -nodisplay -nojvm -r '3*4, pause(1); exit'