linux任务后台运行的几种方法
- disown
bash task.sh
ctl z
bg
# 加上-h选项之后当前会话jobs能看到对应的job,但是关闭当前会话,job的父进程会切换到1,不会收到SIGHUP信号
disown -h %1
#直接切换对应pid的owner
disown pid
- screen
# create session with specific name
screen -S session_name
# resume from the default session
screen -r
# resume from the specific session name
screen -r <name>
# list all screen sessions
screen -ls
# detach from current screen session
ctl a d
# exit and kill current screen session
ctl d
- nohup
nohup bash task.sh &> task.log &