Search code examples
nohuplxclxd

how to keep jobs with nohup in lxd


I made python script that needs to run background. This script is in lxd image which is running (checked by 'lxc list')

got into image and tried to keep it run in background.

local> lxc exec image-name -- bash
image-root> nohup python test.py &

and It worked at this point.

image-root> jobs
--printed test.py jobs

BUT when I got out from image and re-entered it, all jobs gone.

image-root> exit (or ctrl+d)
root> lxc exec image-name -- bash
image-root> jobs
--printed nothing and script is not running in background. WHY?

Solution

  • Are you sure the script is not running? Since you have backgrounded it and nohupped it, and then return in a new bash instance, there is no reason you should see it with the "jobs" command. When doing a quick test I have no problem leaving the job running and returning to see the result still being produced.