Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1355

Python • Re: Can't launch external completely independent of script

$
0
0
suppose your script to be lauched is called SCRIPT; you just have to prefix it by nohup and end it by & and it will be detached fom your thread -python- and cannot be interrupted by python termination

os.system("nohup SCRIPT &")
tested

Code:

pi@raspberrypi:~ $ pythonPython 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import os>>> os.system("nohup sleep 11 &")  # nohup makes it background[size=50][/size]>>> nohup: la sortie est ajoutée à 'nohup.out'quit()pi@raspberrypi:~ $ ps    PID TTY          TIME CMD 372274 pts/2    00:00:00 bash 372624 pts/2    00:00:00 sleep 372638 pts/2    00:00:00 pspi@raspberrypi:~ $ 

Statistics: Posted by dbrion1 — Sat Jan 27, 2024 5:45 pm



Viewing all articles
Browse latest Browse all 1355

Trending Articles