您的位置:首页 > 其它

nohup 与 &, 不挂起与后台

2019-02-20 09:35 26 查看
版权声明:All right reserved 未经允许,禁止转载 https://blog.csdn.net/a308601801/article/details/87775035

1.nohup

意思:no hang up 的缩写,不挂断

用途:不挂断地运行命令

语法:nohup Command [ Arg … ] [ & ]

  无论是否将 nohup 命令的输出重定向到终端,输出都将附加到当前目录的 nohup.out 文件中。

  如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中。

  如果没有文件能创建或打开以用于追加,那么 Command 参数指定的命令不可调用。

退出状态:该命令返回下列出口值:   

  126 可以查找但不能调用 Command 参数指定的命令。   

  127 nohup 命令发生错误或不能查找由 Command 参数指定的命令。   

  否则,nohup 命令的退出状态是 Command 参数指定命令的退出状态。

2.&

用途:在后台运行, 一般两个一起用  nohup command &

eg:

[code]nohup /opt/module/kafka/bin/kafka-server-start.sh /opt/module/kafka/config/server.properties 2>&1 >/dev/null &

/dev/null 的作用

 

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: