Python Forum
getting a script into the background
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getting a script into the background
#1
i have done this, before, in C. i'd like to have my script run itself in the background, with the foreground exiting back to the shell. would it be good enough to just have a copy of itself run through the multiprocessing module and have the parent just exit? should i used an intermediary child process? any general suggestions? any pre-written code?

another aspect of this is that ALL other processes for that user will be terminated soon. this could lead to strange effects Python might not be prepared to handle.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
I'm guessing that you can't auto run in background since the interpreter will run in foreground.
Only thing I can think of that comes close is running from cron and starting in background
Reply
#3
the interpreter needs to be in the same process. multiprocessing would call os.fork which would duplicate the process into parent and child. the parent would exit and the child would continue to run. the shell would get SIGCHLD and prompt for the next command. i'm just wondering if there is a more direct way to do that, like something.enter_process_background().
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020