如何用qsub后台git 删除已提交的节点matlab?(nohup只是git 删除已提交的节点到管理节点,并不是后台)

博客访问: 343128
博文数量: 99
博客积分: 3172
博客等级: 中校
技术积分: 811
注册时间:
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: LINUX
有时我们需要远端服务器上运行MATLAB(当然,也包括其它程序,这里将MATLAB作为一个例子)。但不希望被其它人无意之间关闭,包括shell终端窗口或MATLAB窗口本身(以linux操作系统为例,windows只需作小的改动——可查看MATLAB官方的启动方法说明)。这时,最好的办法就是后台执行,没有任何窗口显示。(当然,可通过命令查看到运行的进程。)
方法如下:
1.用TurboVNC viewer远程接入服务器,输入IP及端口号,密码等信息。
2.进入程序所在文件夹,右键启动shell终端,输入如下命令:
nohup /opt/matlab/R2011a/bin/matlab -nodisplay -nodesktop -nojvm -nosplash -r "NewEval" -logfile "NewEvalOutput.txt" &
回车后,提示:appending output to nohup.out (表示成功执行)
按任意键,出现命令输入提示行,输入exit,退出shell终端。 (注:不要直接关闭。)
3.查看进程运行情况:ps -ef|grep matlab
——当然,也可以以后随时查看,如果不接入服务器,可使用WinScp的控制台,即:
4. WinScp - Console - 输入密码 - 在命令窗口输入3中提到的命令,可查看相关所有的信息,如:用户,进程ID,进程启动时间,已运行时间,输入的命令,等等。(我用的winscp507setup.exe)WinScp功能很强大,但有时直接在console中输入命令传递给服务器执行会出错(执行程序的命令可能会出错,但其它的文件操作命令好像是正常的),因此,如果最初启动程序,很可能还是得远程接入,如:TurboVNC或远程桌面控制,等等。
注:若有更好的方法,希望和大家一起讨论。
下面转载一篇原理性描述的博文(来自CSDN:&):
-------------------------------------------------------------
Unix/Linux下一般想让某个程序在后台运行,很多都是使用 & 在程序结尾来让程序自动运行。比如我们要运行mysql在后台:
&&&&&&&& /usr/local/mysql/bin/mysqld_safe --user=mysql &
 但是我们很多程序并不象mysqld一样可以做成守护进程,可能我们的程序只是普通程序而已,一般这种程序即使使用 & 结尾,如果终端关闭,那么程序也会被关闭。为了能够后台运行,我们需要使用nohup这个命令,比如我们有个start.sh需要在后台运行,并且希望在后台能够一直运行,那么就使用nohup:
&&&&&&&&&&& nohup /root/start.sh &
&&&&&&&&&&在shell中回车后提示:
&&&&&&&&&& [~]$ appending output to nohup.out
&&&&&&原程序的的标准输出被自动改向到当前目录下的nohup.out文件,起到了log的作用。
但是有时候在这一步会有问题,当把终端关闭后,进程会自动被关闭,察看nohup.out可以看到在关闭终端瞬间服务自动关闭。
咨询红旗Linux工程师后,他也不得其解,在我的终端上执行后,他启动的进程竟然在关闭终端后依然运行。
在第二遍给我演示时,我才发现我和他操作终端时的一个细节不同:他是在当shell中提示了nohup成功后还需要按终端上键盘任意键退回到shell输入命令窗口,然后通过在shell中输入exit来退出终端;而我是每次在nohup执行成功后直接点关闭程序按钮关闭终端.。所以这时候会断掉该命令所对应的session,导致nohup对应的进程被通知需要一起shutdown。
这个细节有人和我一样没注意到,所以在这儿记录一下了。
附:nohup命令参考
nohup 命令
  用途:不挂断地运行命令。
  语法:nohup Command [ Arg ... ] [ & ]
  描述:nohup 命令运行由 Command 参数和任何相关的 Arg 参数指定的命令,忽略所有挂断(SIGHUP)信号。在注销后使用 nohup 命令运行后台中的程序。要运行后台中的 nohup 命令,添加 & ( 表示"and"的符号)到命令的尾部。
  无论是否将 nohup 命令的输出重定向到终端,输出都将附加到当前目录的 nohup.out 文件中。如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中。如果没有文件能创建或打开以用于追加,那么 Command 参数指定的命令不可调用。如果标准错误是一个终端,那么把指定的命令写给标准错误的所有输出作为标准输出重定向到相同的文件描述符。
  退出状态:该命令返回下列出口值:
  126 可以查找但不能调用 Command 参数指定的命令。
  127 nohup 命令发生错误或不能查找由 Command 参数指定的命令。
  否则,nohup 命令的退出状态是 Command 参数指定命令的退出状态。
  nohup命令及其输出文件
  nohup命令:如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令。该命令可以在你退出帐户/关闭终端之后继续运行相应的进程。nohup就是不挂起的意思( n ohang up)。
  该命令的一般形式为:nohup command &
  使用nohup命令提交作业
  如果使用nohup命令提交作业,那么在缺省情况下该作业的所有输出都被重定向到一个名为nohup.out的文件中,除非另外指定了输出文件:
  nohup command > myout.file 2>&1 &
  在上面的例子中,输出被重定向到myout.file文件中。
  使用 jobs 查看任务。
  使用 fg %n 关闭。
  另外有两个常用的ftp工具ncftpget和ncftpput,可以实现后台的ftp上传和下载,这样就可以利用这些命令在后台上传和下载文件了。
------------------------------------------------------
阅读(10710) | 评论(0) | 转发(0) |
相关热门文章
给主人留下些什么吧!~~
请登录后评论。[转载][转]Linux 下后台运行Matlab
已有 7945 次阅读
|个人分类:|系统分类:|关键词:后台运行
Matlab|文章来源:转载
后台运行matlab脚本文件的方法:nohup
实现功能:
1. 字符环境下运行matlab.
2.字符环境下运行matlab脚本文件,脚本文件无图像的屏幕输出。
3.脚本文件需长时间运行,运行结果输出到文件。matlab的标准重定向到另一个文件。
4.客户端退出登陆后,matlab保持运行,直到脚本程序结束或错误退出时,matlab程序才退出。
实现方法:采用nohup命令。
具体实现过程:
使用命令:
nohup /usr/matlab/bin/matlab&&
&fill.m& fill.out &
就可以了,fill.m表示你的文件名. fill.out代表你的输出转到fill.out文件中。比如,matlab中的命令sin(1:10),结果应该输出到command window中的,但是现在转到了fill.out文件中
例如:我在/home/jsh/yangting/文件夹下有个test2.m文件
那么,当matlab在/home/jsh/yangting/文件夹下打开时,
nohup matlab &test2.m& fill.out &
注意:在nohup运行成功后,不能直接点击关闭按钮,而应该按下任意键,恢复到输入状态,然后按exit命令退出。
使用命令:
nohup matlab -nojvm -nodisplay -nosplash -nodesktop & matlabscript.m 1&running.log 2&running.err &
nohup matlab -nojvm -nodisplay -nosplash & matlabscript.m 1&running.log 2&running.err &
nohup matlab -nojvm -nodisplay & matlabscript.m 1&running.log 2&running.err &
matlabscript.m是将要运行的脚本文件,存在于服务器上;
running.log是matlab标准屏幕输出的重定向文件,将建立于服务器上;
running.err是matlab运行时的错误重定向文件,将建立于服务器上。
===================================
另外补充:
(1)如果你想中断正在运行的matlab请使用
&&&&&&&&&&&&&
kill -9 进程号
或 fg %n; Ctrl+C
(2)如果你想在字符环境的matlab中运行脚本,请使用
&&&&&&&&&&&&&
run 脚本文件名(不含.m扩展名)
(3)如果你想用ssh运行有X界面的matlab,登陆时请使用
&&&&&&&&&&&&
ssh 主机名 -l 用户名 -X
Running Matlab Remotely (Under Linux)
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
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 ins naturally, this
precludes any graphical output and restricts this use to numerical tasks
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)
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
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
if your job is actually performed by a function, this script file can
simply be a single line that calls your function.
the remaining elements in the command-line above, I am assuming you are
using t 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,建议不要用图形界面选项,执行什么命令预先写在m文件里面,如:
nohup sh 'matlab -nodesktop & /data/user/myCommand.m'
这里的&是输入换向,因为nohup会忽略终端的输入。
要注意,如果是ssh上去的,千万不要直接关窗口,而一定要用exit命令和主机解除关系。
用不用"&"在linux里面不重要。在linux里面,还有更加简便的方法。并且还有图形界面
1)可以用screen命令,一般的2.6.12以上的内核都支持。
screen matlab &
这个时候,可以继续用matlab,退出终端用exit就可以了。
如果没有 &。可以到终端,按ctrl-a 挂起,用命令bg将matlab转到后台,注意,这个时候不要忘记最重要的一步,千万人按一键或多按一个回车,然后用exit。要不然,一旦你结束sreen,matlab也就结束了。
2)基于2.6.18以上内核
起先自己一直这么用的,所以也就没有上心。以为linux原本就可以独立终端运行。刚才有看了一下,发现是2.6.16以后的新功能,就是2.6.18以后更加完善了。就是VM机制。当然,需要多核计算机支持。
一个终端在缺省时将试图用VM运行你的程序。ssh
name@server以后,可以直接在linux主机上打开matlab,然后可以看到图形界面,你可以完成你要得工作,需要等待的时候。在终端,按
ctrl-z回到终端命令行,用bg命令置于后台。然后,用exit退出终端。这个时候,你会发现matlab还在你的电脑上运行。不过这个只是图形界
面。并且没有实质性的作用。就是x winserver在你的电脑上的一个 VM界面而已。
另外一点,你的tty输出将存在主机的你的目录下。matlab的屏幕输出就看不见了。所以,务必将结果用标准输出,写入文件。
3)matlab server.
这个针对性比较强,你的电脑需要安装matlabserver支持相关的工具箱,然后可以让server上的其他电脑替你完成你的运算。server的特
殊命令集在工具箱里都有定义,一般的运算和你在本地没有区别。关于server的问题,如果感兴趣很高兴再讨论。
转载本文请联系原作者获取授权,同时请注明本文来自鲍素莹科学网博客。链接地址:
当前推荐数:0
评论 ( 个评论)
扫一扫,分享此博文
作者的其他最新博文
热门博文导读
Powered by
Copyright &查看: 3060|回复: 4|关注: 0
有人用linux吗?linux下如何在后台运行matlab?
<h1 style="color:# 麦片财富积分
新手, 积分 19, 距离下一级还需 31 积分
nohup matlab matfile.m 1&std.out 2&err.out &
<h1 style="color:# 麦片财富积分
好像有一个 at 命令可以,具体不太清楚
<h1 style="color:# 麦片财富积分
俺也想知道啊
<h1 style="color:# 麦片财富积分
openmind 发表于
俺也想知道啊
隔了这么久这帖子居然又被挖出来了
这个问题后来我到matlab官网问过,感兴趣的话可以去搜一下
或者看这里
h ttp:////blog/item/4222ccbf07ef95.html
<h1 style="color:# 麦片财富积分
可用命令如下:
nohup matlab -nojvm -nodisplay & Test.m&&1&running.log 2&running.err
站长推荐 /2
Powered byLinux之nohup命令:实现退出终端后程序继续后台运行 - AndyJee - 博客园
随笔 - 325, 文章 - 0, 评论 - 19, 引用 - 0
  转自:/art/302/5599_1.html
  简单而有用的nohup命令在UNIX/LINUX中,普通进程用&符号放到后台运行,如果启动该程序的控制台logout,则该进程随即终止。
  要实现守护进程,一种方法是按守护进程的规则去编程(本站有文章介绍过),比较麻烦;另一种方法是仍然用普通方法编程,然后用nohup命令启动程序:
      nohup<程序名>&
     则控制台logout后,进程仍然继续运行,起到守护进程的作用(虽然它不是严格意义上的守护进程)。
  使用nohup命令后,原程序的的标准输出被自动改向到当前目录下的nohup.out文件,起到了log的作用,实现了完整的守护进程功能。
      ygwu @ 日 上午10:03
      For example:
  如何远程启动WebLogic服务?
    用telnet远程控制服务器,远程启动WEBLOGIC服务,启动后关闭telnet,WebLogic服务也跟着停止,这是因为使用telnet启动的进程会随着telnet进程的关闭而关闭。所以我们可以使用一些UNIX下的命令来做到不关闭。
    使用如下命令:
    nohup startWeblogic.sh&
    如果想要监控标准输出可以使用:
    tail -f nohup.out
  当在后台运行了程序的时候,可以用jobs命令来查看后台作业的状态。在有多个后台程序时,要使用来参数的fg命令将不同序号的后台作业切换到前台上运行。&
  当用户启动一个进程的时候,这个进程是运行在前台,使用与相应控制终端相联系的标准输入、输出进行输入和输出。即使将进程的输入输出重定向,并将进程放在后台执行,进程仍然和当前终端设备有关系。正因为如此,在当前的登录会话结束时,控制终端设备将和登录进程相脱离,那么系统就向所有与这个终端相联系的进程发送SIGHUP的信号,通知进程线路已经挂起了,如果程序没有接管这个信号的处理,那么缺省的反应是进程结束。因此普通的程序并不能真正脱离登录会话而运行进程,为了使得在系统登录后还可以正常执行,只有使用命令nohup来启动相应程序。
  使用命令nohup当然可以启动这样的程序,但nohup启动的程序在进程执行完毕就退出,而常见的一些服务进程通常永久的运行在后台,不向屏幕输出结果。在Unix中这些永久的后台进程称为守护进程(daemon)。守护进程通常从系统启动时自动开始执行,系统关闭时才停止。
  在守护进程中,最重要的一个是超级守护进程inetd,这个进程接管了大部分网络服务,但并不是对每个服务都自己进行处理,而是依据连接请求,启动不同的服务程序与客户机打交道。inetd支持网络服务种类在它的设置文件/etc/inet.conf中定义。inet.conf文件中的每一行就对应一个端口地址,当inetd接受到连接这个端口的连接请求时,就启动相应的进程进行处理。使用inetd的好处是系统不必启动很多守护进程,从而节约了系统资源,然而使用inetd启动守护进程相应反应会迟缓一些,不适合用于被密集访问的服务进程。MATLAB&后台运行的两种方法
曾经让MATLAB程序在LINUX SEVER &下后台运行,至于为什么要放后台运行,你懂的!
看了很多网页之后才总结出来的.
第一种方法,对一般的单个*.M文件有效:
实现方法:采用nohup命令。
具体实现过程:
使用命令:
/usr/matlab/bin/matlab&&&
fill.out &
就可以了,fill.m表示你的文件名.&fill.out代表你的输出转到fill.out文件中。比如,matlab中的命令sin(1:10),结果应该输出到command
window中的,但是现在转到了fill.out文件中
例如:我在/home/jsh/yangting/文件夹下有个test2.m文件
那么,当matlab在/home/jsh/yangting/文件夹下打开时,
nohup matlab fill.out &
注意:在nohup运行成功后,不能直接点击关闭按钮,而应该按下任意键,恢复到输入状态,然后按exit命令退出。
使用命令:
nohup matlab -nojvm -nodisplay -nosplash -nodesktop &
matlabscript.m 1&running.log 2&running.err &
nohup matlab -nojvm -nodisplay -nosplash & matlabscript.m
1&running.log 2&running.err &
nohup matlab -nojvm -nodisplay & matlabscript.m 1&running.log
2&running.err &
matlabscript.m是将要运行的脚本文件,存在于服务器上;
running.log是matlab标准屏幕输出的重定向文件,将建立于服务器上;
running.err是matlab运行时的错误重定向文件,将建立于服务器上。
-------------------------------------------------------------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!如果上面方法运行有问题的话,下面的方法将是最后的(当然遇到的问题也是下面的管用,所以我推荐第二种方法)!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
---------------------------------------------------------------------------------------------
第二种方法:
nohup matlab -nojvm -nodisplay -nosplash -nodesktop -r go
&(!注意go是M文件go.m的名字,只是去了.m
不知为什么,但一定要这么做)
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

我要回帖

更多关于 matlab 等距节点插值 的文章

 

随机推荐