&

后台运行程序

使用ctrl+c发送SIGINT信号,程序不关闭
关闭session/终端时发送SIGHUP信号,程序关闭

示例:

storm nimbus &

程序运行的信息会输出到终端


nohup

不挂断(no hang up)运行程序

使用ctrl+c发送SIGINT信号,程序关闭
关闭session/终端时发送SIGHUP信号,程序不关闭

示例:

nohup storm nimbus

程序运行的信息会默认输出到nohup.out

也可以指定输出文件

nohup storm nimbus > output.log 2>&1

其中,2>&1的作用是,将标准错误2重定向到标准输出&1,再被重定向输入到output.log文件中。

0 – stdin (standard input,标准输入)
1 – stdout (standard output,标准输出)
2 – stderr (standard error,标准错误输出)

 

* 二者同时使用,可以使后台程序不受ctrl+c和session/终端关闭的影响。

 

相关文章:

  • 2021-07-27
  • 2022-01-14
  • 2021-09-12
  • 2021-09-12
  • 2021-11-11
猜你喜欢
  • 2021-07-25
  • 2022-01-20
  • 2021-07-29
  • 2022-02-07
  • 2021-06-08
  • 2021-09-12
相关资源
相似解决方案