I find it quite long to have to write:
nohup python -u myscript.py > log.txt 2>&1 &
each time I want to launch a Python script as a background process.
Is it possible to have a shebang-like first line of script like:
#!nohup python -u myscript.py > log.txt 2>&1 &
import time
while True:
print 'hello'
time.sleep(1)
such that a command like
run myscript.py
would automatically start the script with the command present in the first line of myscript.py
?
Note: I'm looking for a single-file solution, I don't want to have to have a second file myscript.sh
bash script along myscript.py
to do this job.