I would like to let run my script on background on my server. I red about nohup. I have my script.py. I run it like this:
python3 script.py&
It runs on background even when I close terminal. The script write numbers to file /tmp/aaa.txt every second, started from 0. I disconnect from server and reconnect to it and sow that there is numbers over 3000 (over 50 minutes). So my question is, do I really need to use nohup? If yes/no why?
# hostnamectl
Static hostname: my-server
Icon name: computer-vm
Chassis: vm
Machine ID: XXXX
Boot ID: XXXX
Virtualization: vmware
Operating System: Ubuntu 16.04.3 LTS
Kernel: Linux 4.4.0-116-generic
Architecture: x86-64
My script script.py:
import time
i = 0
while True:
f = open('aaa.txt', 'a+')
f.write('Doing somethign: {0}\n'.format(i))
f.close()
i = i + 1
time.sleep(1)