nohup
удаляет себя из имени запущенного процесса. По этой причине вы не можете найти его с помощью ps ax| grep nohup
.
Проверьте этот файл test.py, который я сделал:
import sys
import time
while True:
time.sleep(0.5)
sys.stdout.write('ok\n')
sys.stdout.flush()
Запуск:
nosklo@stackoverflow:~$ python3 test.py
ok
ok
^CTraceback (most recent call last):
File "test.py", line 4, in <module>
time.sleep(0.5)
KeyboardInterrupt
Теперь с nohup
:
nosklo@stackoverflow:~$ nohup python3 test.py > foo.txt &
nohup: ignoring input and redirecting stderr to stdout
[1] 12453
nosklo@stackoverflow:~$ ps ax | grep -i nohup
nosklo 12548 0.0 0.0 15976 944 pts/17 S+ 14:14 0:00 grep --color=auto -i nohup
nosklo@stackoverflow:~$ ps ax | grep -i python
nosklo 12453 0.0 0.0 31400 5660 pts/17 S 14:13 0:00 python3 test.py
nosklo 12528 0.0 0.0 15976 940 pts/17 S+ 14:14 0:00 grep --color=auto -i python
Как вы можете видеть, он есть с pid 12453
, но без nohup
в названии.
nosklo@stackoverflow:~$ kill %1
[1]+ Terminated nohup python3 test.py > foo.txt
nosklo@stackoverflow:~$ tail foo.txt
ok
ok
ok
....
И все это время работало.