使用nohup在后台运行程序

command

  • 后台启动tomcat:
    nohup catalina.sh run 2>&1 & (标准输出默认为nohup.out)
    nohup catalin.sh run > run.txt 2>&1 & (标准输出也重定向到指定文件run.txt)

  • 格式
    nohup 要执行的命令 >out.file 2>&1 &

命令拆分

catalina.sh run 运行tomcat(或其他我们想要运行的命令)

  • nohup
    nohupno hang up,忽略挂起信号。
    nohup (1) - run a command immune to hangups, with output to a non-tty
  • 2>&1 (注意不可以加空格)
    将标准出错输出2重定向到标准输出&1中。
  • & 在后台运行某命令

nohup

可以使用以下命令来了解要使用的程序。
使用nohup在后台运行程序