Linux nohup和
时间: 2023-12-03 21:16:49 浏览: 99
& 的区别是什么?
Linux中,nohup和&这两个命令都可以让进程在后台运行,但是它们有着不同的作用。&命令可以让进程在后台运行,但是当用户退出终端时,该进程也会随之结束。而nohup命令则可以让进程在后台运行,并且即使用户退出终端,该进程仍然可以继续运行。所以,当需要在后台运行一个进程,而且想让它一直运行下去,即使用户退出终端时,可以使用nohup命令。
相关问题
linux nohup
Linux中的nohup命令是用来在后台运行命令,即使关闭终端或退出Shell,命令仍然会继续运行。nohup命令的基本语法是:
nohup command arguments 或 nohup options。
无论是否将nohup命令的输出重定向到终端,输出都将附加到当前目录的nohup.out文件中。如果当前目录的nohup.out文件不可写,输出将重定向到$HOME/nohup.out文件中。如果没有可用的文件来追加输出,那么指定的命令将无法执行。所以,如果你需要运行一个程序,即使对应的Shell被退出后依然保持运行,可以使用nohup命令运行这个程序。例如,可以使用命令“nohup command”来运行一个程序。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [Linux nohup命令详解](https://blog.csdn.net/Listen2You/article/details/107370975)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [Linux中nohup命令使用介绍](https://blog.csdn.net/y601500359/article/details/113880132)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
linux nohup命令
nohup命令是在Linux和Unix操作系统中使用的一个命令,用于在后台运行命令,不受用户退出终端的影响。
nohup命令的语法如下:
nohup command [arg]...
其中,command是需要在后台运行的命令,arg是命令的参数。
nohup命令的作用是在后台运行命令,并将命令的输出重定向到一个文件中,这样即使用户退出终端,命令也会继续在后台运行。
nohup命令的常用选项:
- -n:不将输出追加到nohup.out文件中。
- -p:指定进程号,将指定进程的输出重定向到nohup.out文件中。
- -s:指定信号,发送指定信号给指定进程。
示例:
nohup ./mycommand &
这个命令会在后台运行mycommand命令,并将输出重定向到nohup.out文件中。
nohup命令的使用场景:
- 长时间运行的命令,如备份、压缩、复制等。
- 需要在后台运行的进程,如服务器、守护进程等。
- 需要在远程连接中运行的命令,如SSH连接等。
注意事项:
- nohup命令不会阻止命令本身出错或崩溃。
- nohup命令不会阻止命令占用过多的系统资源。
- nohup命令会将命令的输出重定向到nohup.out文件中,如果需要保存多个命令的输出,需要将输出重定向到不同的文件中。
阅读全文
相关推荐
















