关于nohup命令
2024-08-30 07:37:04
nohup java -jar Test.jar --server.port=443 > console.log 2>&1 &
- 关于nohup命令
- when using the command shell, prefixing a command with nohup prevents the command from being aborted automatically when you log out or exit the shell.
- the name nohub stands for "no hangup." The hangup signal, which is normally sent to a process to inform it that the user has logged off(or "hung up"), is intercepted by nohub, allowing the process to continue running.
- If standard input is a terminal, nohup redirects it from /dev/null. Therefore, terminal input is not possible when running a command with nohup.
- If standard output is a terminal, command output is appended to the file nohup.out if possible, or $HOME/nohup.out otherwise.
- If standard error is a terminal, it is redirected to standard output.
- To save output to a file named file, use "nohup command > file".
- 英文解释的很清楚,也很容易理解
- nohup命令可以让你退出shell或登录时,命令仍然在后台运行,通常我们是通过在命令最后面添加&来使得命令在后台运行的,但关闭shell或退出登录时,服务就挂了;
- 如果在终端运行nohup,使用<来输入参数是不行的,它重定向输入到了/dev/null,它的默认输出是当前目录下的nohup.out
- 至于我自己为什么会用到nohup,是因为之间在服务器上跑jar包时,总是意外终端,后来才发现是因为退出了shell的原因
关于文件重定向
- 在shell中,每个进程都和三个系统文件相关联:标准输入stdin,标准输出stdout和标准错误stderr,三个系统文件的文件描述符分别为0,1和2。
- > console.log 很容易理解就是 重定向标准输出到console.log
- 2>&1 的意思就是将标准错误也输出到标准输出当中。至于为什么在1前面有个取地址的符号,因为&1就代表标准输出
- 使用下面的例子来练习下
- ls 2>1测试,不会报没有2文件的错误,但会输出一个空的文件1,注意>符号左右别加空格,否则会报错;
- ls xxx 2>1测试,没有xxx这个文件的错误输出到了1中;
- ls xxx 2>&1测试,不会生成1这个文件了,不过错误跑到标准输出了;
- ls xxx >out.txt 2>&1, 实际上可换成 ls xxx 1>out.txt 2>&1;重定向符号>默认是1,错误和输出都传到out.txt了
最新文章
- AIX 环境下减小系统page space空间
- BroadcastReceiver之SD的挂载监听
- URL详解与URL编码
- 14.KVM安装之脚本和镜像目录树准备
- 循序渐进开发WinForm项目(3)--Winform界面层的项目设计
- 在一个XAML中点击按钮,界面跳转到另一个XAML界面方法
- 让git忽略文件模式的改变
- 5月21日 CSS样式表加阴影
- Linux 查看某个用户的进程
- Hadoop 学习笔记(一) HDFS API
- C++在struct与class差异
- 两层嵌套的JSON包的解法
- [Poj3128]Leonardo&#39;s Notebook
- HI3531的nand flash测试
- 细说firewalld和iptables
- Python3基础 if else 格式 输入一个整数并判断是8吗
- ubuntu下搭建testlink
- 深刻理解 React (一) ——JSX和虚拟DOM
- ESP和EBP 栈顶指针和栈底指针
- NestedScrollView,RecyclerView