nohup
(no hang-up)命令用于在后台运行程序,即使关闭终端或断开连接,程序也会继续运行
nohup your_command > output.log 2>&1 &
这里,your_command
是你要运行的命令,output.log
是输出日志文件。2>&1
表示将标准错误(2)重定向到标准输出(1),&
表示将命令放入后台运行。
nohup your_first_command | your_second_command > output.log 2>&1 &
&&
使用:如果你想在第一个命令成功执行后运行第二个命令,可以使用 &&
:nohup your_first_command && your_second_command > output.log 2>&1 &
;
使用:无论第一个命令是否成功执行,都运行第二个命令,可以使用 ;
:nohup your_first_command ; your_second_command > output.log 2>&1 &
请注意,使用 nohup
命令时,最好将输出重定向到一个日志文件,以便在需要时查看程序的输出和错误信息。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>