linuxバックグラウンドでMATLABを実行


バックグラウンドでmatlabスクリプトファイルを実行する方法:nohup実装機能:1.文字環境でmatlabを実行する.2.文字環境でmatlabスクリプトファイルを実行し、スクリプトファイルに画像の画面出力がありません.3.スクリプトファイルを長時間実行し、実行結果をファイルに出力します.matlabの標準は別のファイルにリダイレクトされます.4.クライアントがログインを終了した後、matlabはスクリプトプログラムが終了したり、エラーが終了したりするまで実行を維持します.実装方法:nohupコマンドを使用します.具体的な実装手順:コマンド:nohup/usr/matlab/bin/matlab fill.いいわmはあなたのファイル名を表します.fill.outはあなたの出力を表してfillに移動します.outファイルにあります.例えば、matlabのコマンドsin(1:10)は、結果はcommand windowに出力されるはずだったが、今はfillに移行する.outファイル内
たとえば、/home/jsh/yangting/フォルダの下にtest 2があります.mファイル
では、matlabが/home/jsh/yangting/フォルダの下で開くと、
コマンド:
nohup matlab fill.out &
注意:nohupが正常に実行された後、閉じるボタンを直接クリックするのではなく、任意のキーを押して入力状態に戻り、exitコマンドを押して終了する必要があります.
使用コマンド:nohup matlab-nojvm-nodisplay-nosplash-nodesktoprunning.log 2>running.Err&またはnohup matlab-nojvm-nodisplay-nosplashrunning.log 2>running.Err&または:nohup matlab-nojvm-nodisplayrunning.log 2>running.Err&そのうち:matlabscript.mは、実行するスクリプトファイルであり、サーバ上に存在する.running.logはmatlab標準画面から出力されたリダイレクトファイルであり、サーバ上に構築されます.running.Errはmatlab実行時のエラーリダイレクトファイルであり、サーバに確立されます.
=================================Ctrl+C(2)文字環境のmatlabでスクリプトを実行したい場合はrunスクリプトファイル名(.m拡張子を含まない)を使用します(3)sshでXインタフェースのあるmatlabを実行したい場合は、ログイン時にsshホスト名-lユーザー名-Xを使用します

Running Matlab Remotely (Under Linux)

Usually, it is most effective and convenient to run Matlab locally, in particular for interactive work, but there are a number of reasons why you might want to run Matlab remotely across a network. For instance, your local machine may not have Matlab installed at all, or your local machine may not have sufficient memory for your task. In these cases, you can consider accessing another computer by remote login and running Matlab there. This concept only makes sense under Unix/Linux on the remote machine; Windows or Macintosh do not allow for remote access (as far as I know). Hence, for any new windows to be opened, also your local system needs to be Unix/Linux. However, the performance of such remote windows may be so slow that you will want to avoid them anyway and rather run Matlab purely inside your login shell; naturally, this precludes any graphical output and restricts this use to numerical tasks only. So, we want to start Matlab (i) without its desktop and (ii) without any graphics (including the splash screen); this can be accomplished by saying matlab -nodisplay . You could also use matlab -nodisplay -nojvm , which additionally does not start the JVM. In both cases, attempts to open plot and similar windows might be simply ignored or attempts to open the documentation windows might result in various error messages. The above is the most restrictive way in which to start Matlab. If in fact your local machine is Linux, you could use matlab -nodesktop -nosplash , which (i) does not start the desktop and (ii) suppresses the splash screen (the small window with Matlab's logo and version number that usually pops up briefly). But this way of starting Matlab does start the JVM and you have access to the HelpBrowser as well as to plot windows, if you later so desire (and are willing to wait for those to open, which might take a while depending on your network connection).

Running Matlab in the Background (Under Linux)

The idea of running a job in the background means that a software runs without any user interaction and additionally does not block your login shell. As remote access, this makes only sense under Unix/Linux. It applies both on your local machine, but might be particularly useful on a remote login; as in the previous section, this will be most useful for purely numerical (i.e., non-graphical) jobs.
nohup /matlab -nojvm -nodisplay < driver.m >& driver.log &
Here, the backslash in/matlab circumvents any possible alias you might have for Matlab (just to be on the safe side) and the options -nojvm -nodisplay suppress the starting of the JVM (and the startup of the desktop) and the opening of any windows. The final ampersand ("&") actually puts the command into the background, i.e., gives you the command-line prompt in your shell back. Aside from entering any usual commands now, you could in particular log out, without hanging or killing your job, because of the standard Unix/Linux command nohup before the call to Matlab. The file driver.m that must be present in the current directory is a Matlab script file (not: function file) that lists the commands to be executed by your job; if your job is actually performed by a function, this script file can simply be a single line that calls your function. For the remaining elements in the command-line above, I am assuming you are using the csh or tcsh shell; in other shells, the redirections may be slightly different. The "< "redirects stdin (namely from file driver.m ) into Matlab. For the background run not to hang, there must not be any screen output, so the ">& "redirects both stdout and stderr to the file driver.log ; this file must not exist initially. Again, the redirection commands may be different in other shells and slight variations are possible (such as overwriting an existing log file). linux unixにかかわらず、nohup sh'full command line'でプログラムを起動し、端末とは独立してバックグラウンドでプログラムを実行できます.nohup起動時にグラフィックインタフェースがないため、matlabの場合はグラフィックインタフェースオプションを使用しないで、nohup sh'matlab-nodesktop running.log 2>running.err &