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了

关于nohup命令的更多相关文章

  1. linux–nohup命令(转)

    在应用Unix/Linux时,我们一般想让某个程序在后台运行,于是我们将常会用 & 在程序结尾来让程序自动运行.比如我们要运行mysql在后台: /usr/local/mysql/bin/my ...

  2. 菜鸟学Linux命令:nohup命令启动程序

    在UNIX/LINUX中,普通进程用&符号放到后台运行,如果启动该程序的控制台logout,则该进程随即终止. 要实现守护进程,一种方法是按守护进程的规则去编程,比较麻烦:另一种方法是仍然用普 ...

  3. nohup命令浅析

    要将一个命令放到后台执行,我们一般使用nohup sh command & &都知道是放到后台执行这个命令,那么nohup是做什么的? 这就要从unix的信号说起,unix的信号机制可 ...

  4. Linux_解决nohup命令生成的多余的大日志文件

    解决nohup命令生成的多余的大日志文件 经常使用命令 nohup /usr/bin/php /srv/www/update.php & 可以让它在后台安静的进行,但是有一个烦恼就是,它会生成 ...

  5. linux 后台运行命令 nohup命令

    转载:http://if.ustc.edu.cn/~ygwu/blog/archives/000538.html 2005年04月18日 简单而有用的nohup命令在UNIX/LINUX中,普通进程用 ...

  6. Linux基础知识之—— nohup命令使程序在后台运行的方法

    在linux操作系统中从后台一直运行某个程序的方法,就是使用nohup命令了. 参照网址:http://www.jb51.net/LINUXjishu/189964.html

  7. linux的nohup命令的用法

    在应用Unix/Linux时,我们一般想让某个程序在后台运行,于是我们将常会用 & 在程序结尾来让程序自动运行.比如我们要运行mysql在后台: /usr/local/mysql/bin/my ...

  8. LINUX nohup命令输入输出深浅进出

    无论是否将 nohup命令的输出重定向到终端,输出都将附加到当前目录的 nohup.out 文件中.如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中 ...

  9. 实用技巧:简单而有用的nohup命令介绍(转)

    简单而有用的nohup命令在UNIX/LINUX中,普通进程用&符号放到后台运行,如果启动该程序的控制台logout,则该进程随即终止. 要实现守护进程,一种方法是按守护进程的规则去编程(本站 ...

  10. Linux nohup命令详解

    nohup命令及其输出文件                                                                                       ...

随机推荐

  1. linux 定时备份mysql

    定时备份:1.创建备份文件存放目录2.创建备份脚本backup.sh #!/bin/bash DBUser=db_backDBPasswd=passwordDBName=db_nameSERVER=l ...

  2. Java-API-Package:java.lang

    ylbtech-Java-API-Package:java.lang 1.返回顶部 1. Package java.lang Provides classes that are fundamental ...

  3. [置顶] 制作开机LOGO就是这么简单!

    转自: http://mp.weixin.qq.com/s?__biz=MzAxNTAyOTczMw==&mid=2649328522&idx=1&sn=64107695fef ...

  4. bitcode编译错误

    xcode编译引用的静态库可能会出现编译错误: does not contain bitcode. You must rebuild it with bitcode enabled (Xcode se ...

  5. [Python Study Notes]pandas.DataFrame.plot()函数绘图

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  6. ruby 数组与散列

    def say_goodnight(name) result ="Good night ." +name return result end def say_goodmorning ...

  7. gearman安装问题总结

    解决configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. yum ...

  8. 【摘自张宴的"实战:Nginx"】使用nginx的proxy_cache模块替代squid,缓存静态文件

    #user nobody;worker_processes 1; error_log logs/static_source.error.log;#error_log logs/error.log no ...

  9. 最短路径Dijkstar算法和Floyd算法详解(c语言版)

    博客转载自:https://blog.csdn.net/crescent__moon/article/details/16986765 先说说Dijkstra吧,这种算法只能求单源最短路径,那么什么是 ...

  10. GTK编程

    一.简介 GTK(GIMP Toolkit)是一套跨多种平台的图形工具包,按LGPL许可协议发布的.虽然最初是为GIMP写的,但早已发展为一个功能强大.设计灵活的通用图形库.特别是被GNOME选中使得 ...