matlab -nosplash -nodesktop -r "my_script; quit"
Edit:
Following Eric's recommendation, you better use one of them:
matlab -nosplash -nodesktop -r "try, my_script; end, quit"
matlab -nosplash -nodesktop -r "try, my_script; catch, disp('failed'), end, quit"
matlab -nosplash -nodesktop -r "try, my_script; catch e, your_error_handling_function(e), end, quit"
source
share