nohup

How do I put an already-running process under nohup?

别来无恙 提交于 2019-11-26 13:54:34
I have a process that is already running for a long time and don't want to end it. How do I put it under nohup (that is, how do I cause it to continue running even if I close the terminal?) Node Using the Job Control of bash to send the process into the background: Ctrl + Z to stop (pause) the program and get back to the shell. bg to run it in the background. disown -h [job-spec] where [job-spec] is the job number (like %1 for the first running job; find about your number with the jobs command) so that the job isn't killed when the terminal closes. Suppose for some reason Ctrl + Z is also not

Run a program from python, and have it continue to run after the script is killed

谁都会走 提交于 2019-11-26 11:44:37
I've tried running things like this: subprocess.Popen(['nohup', 'my_command'], stdout=open('/dev/null', 'w'), stderr=open('logfile.log', 'a')) This works if the parent script exits gracefully, but if I kill the script (Ctrl-C), all my child processes are killed too. Is there a way to avoid this? The platforms I care about are OS X and Linux, using Python 2.6 and Python 2.7. edoloughlin The usual way to do this on Unix systems is to fork and exit if you're the parent. Have a look at os.fork() . Here's a function that does the job: def spawnDaemon(func): # do the UNIX double-fork magic, see

is it possible to use variables in remote ssh command?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 11:34:47
问题 I\'d like to execute several commands in sequence on a remote machine, and some of the later commands depend on earlier ones. In the simplest possible example I get this: ssh my_server \"echo this is my_server; abc=2;\" this is my_server abc=2: Command not found. ssh my_server \"echo this is my_server; abc=2; echo abc is $abc\" abc: undefined variable For a bit of background info, what I actually want to do is piece together a path and launch a java application: ssh my_server \'nohup sh -c \"

What's the nohup on Windows?

自闭症网瘾萝莉.ら 提交于 2019-11-26 11:05:48
问题 I want to run a Java jar file like this: java -jar spider.jar How to run it on the background on Windows? Like this on Linux: nohup java -jar spider.jar > /var/tmp/spider.log 2>&1 & 回答1: On Windows it's not normal that a process terminates once its parent was killed (like Unix-likes do it normally). Therefore there is no direct necessity for something like nohup . If you want to avoid the console window associated with it, you can use javaw but redirection won't work, then. 回答2: You could use

How to get the process ID to kill a nohup process?

社会主义新天地 提交于 2019-11-26 07:50:51
问题 I\'m running a nohup process on the server. When I try to kill it my putty console closes instead. this is how I try to find the process ID: ps -ef |grep nohup this is the command to kill kill -9 1787 787 回答1: When using nohup and you put the task in the background, the background operator ( & ) will give you the PID at the command prompt. If your plan is to manually manage the process, you can save that PID and use it later to kill the process if needed, via kill PID or kill -9 PID (if you

How do I put an already-running process under nohup?

一个人想着一个人 提交于 2019-11-26 05:54:48
问题 I have a process that is already running for a long time and don\'t want to end it. How do I put it under nohup (that is, how do I cause it to continue running even if I close the terminal?) 回答1: Using the Job Control of bash to send the process into the background: Ctrl + Z to stop (pause) the program and get back to the shell. bg to run it in the background. disown -h [job-spec] where [job-spec] is the job number (like %1 for the first running job; find about your number with the jobs

What's the difference between nohup and ampersand

房东的猫 提交于 2019-11-26 04:03:44
问题 Both nohup myprocess.out & or myprocess.out & set myprocess.out to run in the background. After I shutdown the terminal, the process is still running. What\'s the difference between them? 回答1: nohup catches the hangup signal (see man 7 signal ) while the ampersand doesn't (except the shell is confgured that way or doesn't send SIGHUP at all). Normally, when running a command using & and exiting the shell afterwards, the shell will terminate the sub-command with the hangup signal ( kill

Run a program from python, and have it continue to run after the script is killed

北城余情 提交于 2019-11-26 03:33:51
问题 I\'ve tried running things like this: subprocess.Popen([\'nohup\', \'my_command\'], stdout=open(\'/dev/null\', \'w\'), stderr=open(\'logfile.log\', \'a\')) This works if the parent script exits gracefully, but if I kill the script (Ctrl-C), all my child processes are killed too. Is there a way to avoid this? The platforms I care about are OS X and Linux, using Python 2.6 and Python 2.7. 回答1: The usual way to do this on Unix systems is to fork and exit if you're the parent. Have a look at os

Linux终端复合软件

萝らか妹 提交于 2019-11-26 02:05:57
需求 1、当网络连接状态不好的时候,不会导致命令中断 2、用户需要长时间运行的命令。 1、nohup/setsid/& 参考资料: https://blog.csdn.net/stpeace/article/details/76389073 https://blog.csdn.net/u011095110/article/details/78666833 https://www.ibm.com/developerworks/cn/linux/l-cn-nohup/ 先来图 以上解释下 1、先nohup运行ping命令,会发现其是在bash下运行的进程 2、然后Ctrl+c,发送了信号给bash,nohup被中断了 3、nohup+&, 4、此时logout退出终端,发现ping命令依然在,但是其父进程id为1。 2、disdown 3、screen 参考资料: http://man.linuxde.net/screen https://wiki.archlinux.org/index.php/GNU_Screen_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87 ) 别说话,先来张图 参数 含义 命令行参数 -ls 显示目前所有的screen作业 -wipe 检查目前所有的screen作业,并删除已经无法使用的screen作业 -S 新建一个会话 -d