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?)
我如何把它放在nohup(也就是,我如何使它继续运行,即使我关闭终端?)
10 个解决方案
#1
1107
Using the Job Control of bash to send the process into the background:
使用bash的作业控制将流程发送到后台:
- Ctrl+Z to stop (pause) the program and get back to the shell.
- 按Ctrl+Z停止(暂停)程序并返回到shell。
-
bg
to run it in the background. - bg在后台运行它。
-
disown -h [job-spec]
where [job-spec] is the job number (like%1
for the first running job; find about your number with thejobs
command) so that the job isn't killed when the terminal closes. - [职业规范]指的是职位编号(比如第一份工作的%1);找到你的电话号码和工作命令),这样工作就不会在终端关闭时被杀死。
#2
133
Suppose for some reason Ctrl+Z is also not working, go to another terminal, find the process id (using ps
) and run:
假设由于某些原因,Ctrl+Z也不工作,转到另一个终端,找到进程id(使用ps)并运行:
kill -20 PID
kill -18 PID
kill -20
(SIGTSTP
) will suspend the process and kill -18
(SIGCONT
) will resume the process, in background. So now, closing both your terminals won't stop your process.
kill -20 (SIGTSTP)将中止进程,kill -18 (SIGCONT)将在后台恢复进程。所以现在,关闭两个终端不会停止你的进程。
#3
71
The command to separate a running job from the shell ( = makes it nohup) is disown
and a basic shell-command.
将正在运行的作业从shell中分离出来的命令是disown和一个基本的shell命令。
From bash-manpage (man bash):
从bash-manpage(bash):
disown [-ar] [-h] [jobspec ...]
disown [-ar] [-h] [jobspec…]
Without options, each jobspec is removed from the table of active jobs. If the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is present, and neither the -a nor the -r option is supplied, the current job is used. If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs. The return value is 0 unless a jobspec does not specify a valid job.
没有选项,每个jobspec将从活动作业表中删除。如果给出了-h选项,那么每个jobspec都不会从表中删除,而是被标记为这样,如果shell接收到一个SIGHUP,就不会将SIGHUP发送到作业中。如果没有提供jobspec,而且a和-r选项都没有提供,则使用当前作业。如果没有提供jobspec, -a选项意味着删除或标记所有作业;没有jobspec参数的-r选项限制了运行作业的操作。除非jobspec没有指定有效的作业,否则返回值为0。
That means, that a simple
这意味着,这很简单。
disown -a
will remove all jobs from the job-table and makes them nohup
将所有的工作从工作表中删除,并使之成为nohup ?
#4
58
These are good answers above, I just wanted to add a clarification:
以上是很好的答案,我只是想澄清一下:
You can't disown
a pid or process, you disown
a job, and that is an important distinction.
你不能放弃一个pid或过程,你失去了一个工作,这是一个重要的区别。
A job is something that is a notion of a process that is attached to a shell, therefore you have to throw the job into the background (not suspend it) and then disown it.
一份工作是一种附加到外壳上的过程的概念,因此你必须把工作投入到背景中(而不是暂停),然后放弃它。
Issue:
问题:
% jobs
[1] running java
[2] suspended vi
% disown %1
See http://www.quantprinciple.com/invest/index.php/docs/tipsandtricks/unix/jobcontrol/ for a more detailed discussion of Unix Job Control.
有关Unix作业控制的更详细的讨论,请参见http://www.quantprinciple.com/invest/index.php/docs/tipsands/unix/jobcontrol/。
#5
36
Unrfortunately disown
is specific to bash and not available in all shells.
不幸的是,disown是特定于bash的,在所有shell中都不可用。
Certain flavours of Unix (e.g. AIX and Solaris) have an option on the nohup
command itself which can be applied to a running process:
Unix(例如AIX和Solaris)的某些特性在nohup命令本身上有一个选项,可以应用于正在运行的进程:
nohup -p pid
See http://en.wikipedia.org/wiki/Nohup
参见http://en.wikipedia.org/wiki/Nohup
#6
20
Node's answer is really great, but it left open the question how can get stdout and stderr redirected. I found a solution on Unix & Linux, but it is also not complete. I would like to merge these two solutions. Here it is:
Node的回答非常好,但是它留下了一个问题,如何让stdout和stderr重定向。我在Unix和Linux上找到了一个解决方案,但它也不完整。我想合并这两个解。这里是:
For my test I made a small bash script called loop.sh, which prints the pid of itself with a minute sleep in an infinite loop.
在我的测试中,我创建了一个名为loop的小型bash脚本。sh,它在无限循环中以一分钟的睡眠输出自己的pid。
$./loop.sh
Now get the PID of this process somehow. Usually ps -C loop.sh
is good enough, but it is printed in my case.
现在来看看这个过程的PID。通常ps - c循环。sh已经够好了,但它已经印在我的箱子里了。
Now we can switch to another terminal (or press ^Z and in the same terminal). Now gdb
should be attached to this process.
现在我们可以切换到另一个终端(或按^ Z和在同一终端)。现在gdb应该附加到这个过程中。
$ gdb -p <PID>
This stops the script (if running). Its state can be checked by ps -f <PID>
, where the STAT
field is 'T+' (or in case of ^Z 'T'), which means (man ps(1))
这将停止脚本(如果运行)。其状态可以通过ps - f < PID >,检查统计领域的“T +”(或在^ Z ' T '),这意味着(男人ps(1))
T Stopped, either by a job control signal or because it is being traced
+ is in the foreground process group
(gdb) call close(1)
$1 = 0
Close(1) returns zero on success.
关闭(1)成功返回零。
(gdb) call open("loop.out", 01102, 0600)
$6 = 1
Open(1) returns the new file descriptor if successful.
打开(1)返回新的文件描述符,如果成功。
This open is equal with open(path, O_TRUNC|O_CREAT|O_RDWR, S_IRUSR|S_IWUSR)
. Instead of O_RDWR
O_WRONLY
could be applied, but /usr/sbin/lsof
says 'u' for all std* file handlers (FD
column), which is O_RDWR
.
这个open等于open(path, O_TRUNC|O_CREAT|O_RDWR, S_IRUSR|S_IWUSR)。而不是O_RDWR O_WRONLY可以应用,但是/usr/sbin/lsof对所有std*文件处理程序(FD列)表示“u”,即O_RDWR。
I checked the values in /usr/include/bits/fcntl.h header file.
我检查了/usr/include/bits/fcntl中的值。h头文件。
The output file could be opened with O_APPEND
, as nohup
would do, but this is not suggested by man open(2)
, because of possible NFS problems.
输出文件可以用O_APPEND打开,因为nohup会这样做,但是这不是man open(2)所建议的,因为可能存在NFS问题。
If we get -1 as a return value, then call perror("")
prints the error message. If we need the errno, use p errno
gdb comand.
如果我们得到-1作为返回值,则调用perror(“”)输出错误消息。如果我们需要errno,请使用p errno gdb comand。
Now we can check the newly redirected file. /usr/sbin/lsof -p <PID>
prints:
现在我们可以检查新重定向的文件。/usr/sbin/lsof - p < PID >打印:
loop.sh <PID> truey 1u REG 0,26 0 15008411 /home/truey/loop.out
If we want, we can redirect stderr to another file, if we want to using call close(2)
and call open(...)
again using a different file name.
如果我们想要,我们可以将stderr重定向到另一个文件,如果我们想使用call close(2)并再次使用不同的文件名调用open(…)。
Now the attached bash
has to be released and we can quit gdb
:
现在附加的bash必须被释放,我们可以退出gdb:
(gdb) detach
Detaching from program: /bin/bash, process <PID>
(gdb) q
If the script was stopped by gdb
from an other terminal it continues to run. We can switch back to loop.sh's terminal. Now it does not write anything to the screen, but running and writing into the file. We have to put it into the background. So press ^Z
.
如果脚本被gdb从另一个终端拦截,它将继续运行。我们可以切换回循环。sh的终端。现在它不写任何东西到屏幕上,而是运行和写入文件。我们必须把它放到后台。所以新闻^ Z。
^Z
[1]+ Stopped ./loop.sh
(Now we are in the same state as if ^Z
was pressed at the beginning.)
(现在我们处于同一状态,就像刚开始时一样。)
Now we can check the state of the job:
现在我们可以检查工作状态:
$ ps -f 24522
UID PID PPID C STIME TTY STAT TIME CMD
<UID> <PID><PPID> 0 11:16 pts/36 S 0:00 /bin/bash ./loop.sh
$ jobs
[1]+ Stopped ./loop.sh
So process should be running in the background and detached from the terminal. The number in the jobs
command's output in square brackets identifies the job inside bash
. We can use in the following built in bash
commands applying a '%' sign before the job number :
所以进程应该在后台运行,并与终端分离。job命令中在方括号中输出的数字标识了bash中的作业。我们可以在下面构建的bash命令中使用“%”符号在作业编号之前:
$ bg %1
[1]+ ./loop.sh &
$ disown -h %1
$ ps -f <PID>
UID PID PPID C STIME TTY STAT TIME CMD
<UID> <PID><PPID> 0 11:16 pts/36 S 0:00 /bin/bash ./loop.sh
And now we can quit from the calling bash. The process continues running in the background. If we quit its PPID become 1 (init(1) process) and the control terminal become unknown.
现在我们可以退出调用bash。进程在后台继续运行。如果我们退出,它的PPID就变成了1 (init(1)进程),而控制终端变得未知。
$ ps -f <PID>
UID PID PPID C STIME TTY STAT TIME CMD
<UID> <PID> 1 0 11:16 ? S 0:00 /bin/bash ./loop.sh
$ /usr/bin/lsof -p <PID>
...
loop.sh <PID> truey 0u CHR 136,36 38 /dev/pts/36 (deleted)
loop.sh <PID> truey 1u REG 0,26 1127 15008411 /home/truey/loop.out
loop.sh <PID> truey 2u CHR 136,36 38 /dev/pts/36 (deleted)
COMMENT
评论
The gdb stuff can be automatized creating a file (e.g. loop.gdb) containing the commands and run gdb -q -x loop.gdb -p <PID>
. My loop.gdb looks like this:
gdb可以自动创建一个包含命令并运行gdb -q -x循环的文件(例如loop.gdb)。gdb - p < PID >。我的循环。gdb是这样的:
call close(1)
call open("loop.out", 01102, 0600)
# call close(2)
# call open("loop.err", 01102, 0600)
detach
quit
Or one can use the following one liner instead:
或者你可以用下面的一行来代替:
gdb -q -ex 'call close(1)' -ex 'call open("loop.out", 01102, 0600)' -ex detach -ex quit -p <PID>
I hope this is a fairly complete description of the solution.
我希望这是对解决方案的一个相当完整的描述。
#7
5
To send running process to nohup (http://en.wikipedia.org/wiki/Nohup)
将运行过程发送到nohup (http://en.wikipedia.org/wiki/Nohup)
nohup -p pid
, it did not worked for me
我不喜欢它,它对我不起作用。
Then I tried the following commands and it worked very fine
然后我尝试了以下命令,效果很好。
-
Run some SOMECOMMAND, say
/usr/bin/python /vol/scripts/python_scripts/retention_all_properties.py 1
.运行一些SOMECOMMAND,比如/usr/bin/python /vol/脚本/python_scripts/retention_all_properties。py 1。
-
Ctrl+Z to stop (pause) the program and get back to the shell.
按Ctrl+Z停止(暂停)程序并返回到shell。
-
bg
to run it in the background.bg在后台运行它。
-
disown -h
so that the process isn't killed when the terminal closes.disown -h,这样当终端关闭时,进程就不会被杀死。
-
Type
exit
to get out of the shell because now you're good to go as the operation will run in the background in its own process, so it's not tied to a shell.类型退出来退出shell,因为现在你很好,因为操作将在后台运行,所以它没有绑定到shell。
This process is the equivalent of running nohup SOMECOMMAND
.
这个过程相当于运行nohup SOMECOMMAND。
#8
2
This worked for me on Ubuntu linux while in tcshell.
这在我在tcshell中为我在Ubuntu linux上工作。
-
CtrlZ to pause it
CtrlZ暂停它
-
bg to run in background
bg在后台运行。
-
jobs to get its job number
找到工作号码的工作。
-
nohup %n where n is the job number
nohup %n,其中n是工作编号。
#9
1
On my AIX system, I tried
在我的AIX系统上,我尝试了。
nohup -p processid>
This worked well. It continued to run my process even after closing terminal windows. We have ksh as default shell so the bg
and disown
commands didn't work.
这工作得很好。即使关闭了终端窗口,它仍然运行我的进程。我们有ksh作为默认shell,所以bg和disown命令不起作用。
#10
0
- CTRL + z => tHIS WILL PAUSE THE JOB (not going to cancel!)
- CTRL + z =>这将暂停工作(不会取消!)
- bg => THIS WILL PUT THE JOB IN BACKGROUND AND RETURN IN RUNNING PROCESS
- 这将使作业在后台运行,并在运行过程中返回。
- disown -a => THIS WILL CUT ALL THE ATTACHMENT WITH JOB (so you can close the terminal and it will still run)
- disown -a =>这将切断所有与作业的连接(所以您可以关闭终端,它仍然会运行)
THESE SIMPLE STEPS WILL ALLOW, YOU CAN CLOSE THE TERMINAL AND IT WILL BE STILL RUNNING BUT IT WONT PUT ON nohub (based on your question, you don't need nohup)
这些简单的步骤将允许,你可以关闭终端,它仍在运行,但它不会安装nohub(基于你的问题,你不需要nohup)
#1
1107
Using the Job Control of bash to send the process into the background:
使用bash的作业控制将流程发送到后台:
- Ctrl+Z to stop (pause) the program and get back to the shell.
- 按Ctrl+Z停止(暂停)程序并返回到shell。
-
bg
to run it in the background. - bg在后台运行它。
-
disown -h [job-spec]
where [job-spec] is the job number (like%1
for the first running job; find about your number with thejobs
command) so that the job isn't killed when the terminal closes. - [职业规范]指的是职位编号(比如第一份工作的%1);找到你的电话号码和工作命令),这样工作就不会在终端关闭时被杀死。
#2
133
Suppose for some reason Ctrl+Z is also not working, go to another terminal, find the process id (using ps
) and run:
假设由于某些原因,Ctrl+Z也不工作,转到另一个终端,找到进程id(使用ps)并运行:
kill -20 PID
kill -18 PID
kill -20
(SIGTSTP
) will suspend the process and kill -18
(SIGCONT
) will resume the process, in background. So now, closing both your terminals won't stop your process.
kill -20 (SIGTSTP)将中止进程,kill -18 (SIGCONT)将在后台恢复进程。所以现在,关闭两个终端不会停止你的进程。
#3
71
The command to separate a running job from the shell ( = makes it nohup) is disown
and a basic shell-command.
将正在运行的作业从shell中分离出来的命令是disown和一个基本的shell命令。
From bash-manpage (man bash):
从bash-manpage(bash):
disown [-ar] [-h] [jobspec ...]
disown [-ar] [-h] [jobspec…]
Without options, each jobspec is removed from the table of active jobs. If the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is present, and neither the -a nor the -r option is supplied, the current job is used. If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs. The return value is 0 unless a jobspec does not specify a valid job.
没有选项,每个jobspec将从活动作业表中删除。如果给出了-h选项,那么每个jobspec都不会从表中删除,而是被标记为这样,如果shell接收到一个SIGHUP,就不会将SIGHUP发送到作业中。如果没有提供jobspec,而且a和-r选项都没有提供,则使用当前作业。如果没有提供jobspec, -a选项意味着删除或标记所有作业;没有jobspec参数的-r选项限制了运行作业的操作。除非jobspec没有指定有效的作业,否则返回值为0。
That means, that a simple
这意味着,这很简单。
disown -a
will remove all jobs from the job-table and makes them nohup
将所有的工作从工作表中删除,并使之成为nohup ?
#4
58
These are good answers above, I just wanted to add a clarification:
以上是很好的答案,我只是想澄清一下:
You can't disown
a pid or process, you disown
a job, and that is an important distinction.
你不能放弃一个pid或过程,你失去了一个工作,这是一个重要的区别。
A job is something that is a notion of a process that is attached to a shell, therefore you have to throw the job into the background (not suspend it) and then disown it.
一份工作是一种附加到外壳上的过程的概念,因此你必须把工作投入到背景中(而不是暂停),然后放弃它。
Issue:
问题:
% jobs
[1] running java
[2] suspended vi
% disown %1
See http://www.quantprinciple.com/invest/index.php/docs/tipsandtricks/unix/jobcontrol/ for a more detailed discussion of Unix Job Control.
有关Unix作业控制的更详细的讨论,请参见http://www.quantprinciple.com/invest/index.php/docs/tipsands/unix/jobcontrol/。
#5
36
Unrfortunately disown
is specific to bash and not available in all shells.
不幸的是,disown是特定于bash的,在所有shell中都不可用。
Certain flavours of Unix (e.g. AIX and Solaris) have an option on the nohup
command itself which can be applied to a running process:
Unix(例如AIX和Solaris)的某些特性在nohup命令本身上有一个选项,可以应用于正在运行的进程:
nohup -p pid
See http://en.wikipedia.org/wiki/Nohup
参见http://en.wikipedia.org/wiki/Nohup
#6
20
Node's answer is really great, but it left open the question how can get stdout and stderr redirected. I found a solution on Unix & Linux, but it is also not complete. I would like to merge these two solutions. Here it is:
Node的回答非常好,但是它留下了一个问题,如何让stdout和stderr重定向。我在Unix和Linux上找到了一个解决方案,但它也不完整。我想合并这两个解。这里是:
For my test I made a small bash script called loop.sh, which prints the pid of itself with a minute sleep in an infinite loop.
在我的测试中,我创建了一个名为loop的小型bash脚本。sh,它在无限循环中以一分钟的睡眠输出自己的pid。
$./loop.sh
Now get the PID of this process somehow. Usually ps -C loop.sh
is good enough, but it is printed in my case.
现在来看看这个过程的PID。通常ps - c循环。sh已经够好了,但它已经印在我的箱子里了。
Now we can switch to another terminal (or press ^Z and in the same terminal). Now gdb
should be attached to this process.
现在我们可以切换到另一个终端(或按^ Z和在同一终端)。现在gdb应该附加到这个过程中。
$ gdb -p <PID>
This stops the script (if running). Its state can be checked by ps -f <PID>
, where the STAT
field is 'T+' (or in case of ^Z 'T'), which means (man ps(1))
这将停止脚本(如果运行)。其状态可以通过ps - f < PID >,检查统计领域的“T +”(或在^ Z ' T '),这意味着(男人ps(1))
T Stopped, either by a job control signal or because it is being traced
+ is in the foreground process group
(gdb) call close(1)
$1 = 0
Close(1) returns zero on success.
关闭(1)成功返回零。
(gdb) call open("loop.out", 01102, 0600)
$6 = 1
Open(1) returns the new file descriptor if successful.
打开(1)返回新的文件描述符,如果成功。
This open is equal with open(path, O_TRUNC|O_CREAT|O_RDWR, S_IRUSR|S_IWUSR)
. Instead of O_RDWR
O_WRONLY
could be applied, but /usr/sbin/lsof
says 'u' for all std* file handlers (FD
column), which is O_RDWR
.
这个open等于open(path, O_TRUNC|O_CREAT|O_RDWR, S_IRUSR|S_IWUSR)。而不是O_RDWR O_WRONLY可以应用,但是/usr/sbin/lsof对所有std*文件处理程序(FD列)表示“u”,即O_RDWR。
I checked the values in /usr/include/bits/fcntl.h header file.
我检查了/usr/include/bits/fcntl中的值。h头文件。
The output file could be opened with O_APPEND
, as nohup
would do, but this is not suggested by man open(2)
, because of possible NFS problems.
输出文件可以用O_APPEND打开,因为nohup会这样做,但是这不是man open(2)所建议的,因为可能存在NFS问题。
If we get -1 as a return value, then call perror("")
prints the error message. If we need the errno, use p errno
gdb comand.
如果我们得到-1作为返回值,则调用perror(“”)输出错误消息。如果我们需要errno,请使用p errno gdb comand。
Now we can check the newly redirected file. /usr/sbin/lsof -p <PID>
prints:
现在我们可以检查新重定向的文件。/usr/sbin/lsof - p < PID >打印:
loop.sh <PID> truey 1u REG 0,26 0 15008411 /home/truey/loop.out
If we want, we can redirect stderr to another file, if we want to using call close(2)
and call open(...)
again using a different file name.
如果我们想要,我们可以将stderr重定向到另一个文件,如果我们想使用call close(2)并再次使用不同的文件名调用open(…)。
Now the attached bash
has to be released and we can quit gdb
:
现在附加的bash必须被释放,我们可以退出gdb:
(gdb) detach
Detaching from program: /bin/bash, process <PID>
(gdb) q
If the script was stopped by gdb
from an other terminal it continues to run. We can switch back to loop.sh's terminal. Now it does not write anything to the screen, but running and writing into the file. We have to put it into the background. So press ^Z
.
如果脚本被gdb从另一个终端拦截,它将继续运行。我们可以切换回循环。sh的终端。现在它不写任何东西到屏幕上,而是运行和写入文件。我们必须把它放到后台。所以新闻^ Z。
^Z
[1]+ Stopped ./loop.sh
(Now we are in the same state as if ^Z
was pressed at the beginning.)
(现在我们处于同一状态,就像刚开始时一样。)
Now we can check the state of the job:
现在我们可以检查工作状态:
$ ps -f 24522
UID PID PPID C STIME TTY STAT TIME CMD
<UID> <PID><PPID> 0 11:16 pts/36 S 0:00 /bin/bash ./loop.sh
$ jobs
[1]+ Stopped ./loop.sh
So process should be running in the background and detached from the terminal. The number in the jobs
command's output in square brackets identifies the job inside bash
. We can use in the following built in bash
commands applying a '%' sign before the job number :
所以进程应该在后台运行,并与终端分离。job命令中在方括号中输出的数字标识了bash中的作业。我们可以在下面构建的bash命令中使用“%”符号在作业编号之前:
$ bg %1
[1]+ ./loop.sh &
$ disown -h %1
$ ps -f <PID>
UID PID PPID C STIME TTY STAT TIME CMD
<UID> <PID><PPID> 0 11:16 pts/36 S 0:00 /bin/bash ./loop.sh
And now we can quit from the calling bash. The process continues running in the background. If we quit its PPID become 1 (init(1) process) and the control terminal become unknown.
现在我们可以退出调用bash。进程在后台继续运行。如果我们退出,它的PPID就变成了1 (init(1)进程),而控制终端变得未知。
$ ps -f <PID>
UID PID PPID C STIME TTY STAT TIME CMD
<UID> <PID> 1 0 11:16 ? S 0:00 /bin/bash ./loop.sh
$ /usr/bin/lsof -p <PID>
...
loop.sh <PID> truey 0u CHR 136,36 38 /dev/pts/36 (deleted)
loop.sh <PID> truey 1u REG 0,26 1127 15008411 /home/truey/loop.out
loop.sh <PID> truey 2u CHR 136,36 38 /dev/pts/36 (deleted)
COMMENT
评论
The gdb stuff can be automatized creating a file (e.g. loop.gdb) containing the commands and run gdb -q -x loop.gdb -p <PID>
. My loop.gdb looks like this:
gdb可以自动创建一个包含命令并运行gdb -q -x循环的文件(例如loop.gdb)。gdb - p < PID >。我的循环。gdb是这样的:
call close(1)
call open("loop.out", 01102, 0600)
# call close(2)
# call open("loop.err", 01102, 0600)
detach
quit
Or one can use the following one liner instead:
或者你可以用下面的一行来代替:
gdb -q -ex 'call close(1)' -ex 'call open("loop.out", 01102, 0600)' -ex detach -ex quit -p <PID>
I hope this is a fairly complete description of the solution.
我希望这是对解决方案的一个相当完整的描述。
#7
5
To send running process to nohup (http://en.wikipedia.org/wiki/Nohup)
将运行过程发送到nohup (http://en.wikipedia.org/wiki/Nohup)
nohup -p pid
, it did not worked for me
我不喜欢它,它对我不起作用。
Then I tried the following commands and it worked very fine
然后我尝试了以下命令,效果很好。
-
Run some SOMECOMMAND, say
/usr/bin/python /vol/scripts/python_scripts/retention_all_properties.py 1
.运行一些SOMECOMMAND,比如/usr/bin/python /vol/脚本/python_scripts/retention_all_properties。py 1。
-
Ctrl+Z to stop (pause) the program and get back to the shell.
按Ctrl+Z停止(暂停)程序并返回到shell。
-
bg
to run it in the background.bg在后台运行它。
-
disown -h
so that the process isn't killed when the terminal closes.disown -h,这样当终端关闭时,进程就不会被杀死。
-
Type
exit
to get out of the shell because now you're good to go as the operation will run in the background in its own process, so it's not tied to a shell.类型退出来退出shell,因为现在你很好,因为操作将在后台运行,所以它没有绑定到shell。
This process is the equivalent of running nohup SOMECOMMAND
.
这个过程相当于运行nohup SOMECOMMAND。
#8
2
This worked for me on Ubuntu linux while in tcshell.
这在我在tcshell中为我在Ubuntu linux上工作。
-
CtrlZ to pause it
CtrlZ暂停它
-
bg to run in background
bg在后台运行。
-
jobs to get its job number
找到工作号码的工作。
-
nohup %n where n is the job number
nohup %n,其中n是工作编号。
#9
1
On my AIX system, I tried
在我的AIX系统上,我尝试了。
nohup -p processid>
This worked well. It continued to run my process even after closing terminal windows. We have ksh as default shell so the bg
and disown
commands didn't work.
这工作得很好。即使关闭了终端窗口,它仍然运行我的进程。我们有ksh作为默认shell,所以bg和disown命令不起作用。
#10
0
- CTRL + z => tHIS WILL PAUSE THE JOB (not going to cancel!)
- CTRL + z =>这将暂停工作(不会取消!)
- bg => THIS WILL PUT THE JOB IN BACKGROUND AND RETURN IN RUNNING PROCESS
- 这将使作业在后台运行,并在运行过程中返回。
- disown -a => THIS WILL CUT ALL THE ATTACHMENT WITH JOB (so you can close the terminal and it will still run)
- disown -a =>这将切断所有与作业的连接(所以您可以关闭终端,它仍然会运行)
THESE SIMPLE STEPS WILL ALLOW, YOU CAN CLOSE THE TERMINAL AND IT WILL BE STILL RUNNING BUT IT WONT PUT ON nohub (based on your question, you don't need nohup)
这些简单的步骤将允许,你可以关闭终端,它仍在运行,但它不会安装nohub(基于你的问题,你不需要nohup)