logo

Linux 后台执行命令

王哲峰 / 2023-07-23


目录

查看当前 Linux 后台运行的程序

jobs
jobs -l

命令 &

# test.py 在后台运行,但是程序的 log 会输出到当前终端
./test.py &

# 将 log 重定向到指定的文件
./test.py >> test.log 2>&1 &

命令 nohup

nohup ./test.py &
exit

nohup ./test.py > test.log 2>&1 &
exit

杀死后台运行的任务