后台任务
用户退出后,后台任务可能会结束
用户查看不了其它用户的 jobs 任务
jobs -l
查看后台命令列表,-l
列出 PID 供
使用kill
command &
运行命令后直接至后台ctrl + z
暂停当前命令至后台bg %1
暂停命令继续运行fg %1
将后台命令切换至前台运行kill PID
杀死后台命令
nohup
用户退出后,进程还会继续运行
nohup command &
后台运行命令, 会在当前目录下生成nohup.out
输出文件nohup command1 > output1.log 2>&1 &
将内容输出至另外一个文件tail -f output1.log
查看输出文件nohup command > /dev/null 2>&1 &
不输出日志ps aux | grep command
查看进程的信息
KILL
kill PID
杀死进程kill -9 PID
强制杀死进程kill -STOP PID
暂停进程kill -CONT PID
恢复 STOP 进程
查找进程
ps aux | grep <command>
查找进程pgrep -fl <command>
查找进程htop
查看进程pstree
树形查看进程