How do I run a Python script in the background Ubuntu?

Nguyễn Pháp

New member
How do I run a Python script in the background Ubuntu?
Answer
First, you need to add a shebang line in the Python script which looks like the following:
  1. #!/usr/bin/env python3. …
  2. chmod +x test.py. …
  3. nohup /path/to/test.py & …
  4. nohup python /path/to/test.py & …
  5. nohup /path/to/test.py > output.log & nohup python /path/to/test.py > output.log & …
  6. ps ax | grep test.py. …
  7. kill PID. …
  8. pkill -f test.py.
19 окт. 2018 г.
 

Tìm kiếm

Back
Top