Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6012753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:26:58+00:00 2026-05-23T02:26:58+00:00

def main(self,argv): do stuff……. if __name__ == ‘__main__’: main(sys.argv[1:]) When my script is run,

  • 0
def main(self,argv):
    do stuff.......

if __name__ == '__main__':
    main(sys.argv[1:])

When my script is run, how can I cause it to immediately run main() as a background process?
It will run to completion and outputs information to a file.

I forgot to say…the goal is to be able to run this on any OS.
I do not want to modify the way the script is called in the command line, I want the script itself to cause it to run in the background.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:26:59+00:00Added an answer on May 23, 2026 at 2:26 am

    easy:

    $ python yourpythonscript.py &
    

    The os will handle that for you 😉 Of course, you will have to state if this is on windows or *nix.

    If you are running this under windows, you might want to check the cmd.exe program – I think there is an option there for running its arguments as a background process…

    Or if you are running this under linux machine, you can check the process by using ps aux | grep yourpythonscript.py

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Ruby, I can define a method foo=(bar) : irb(main):001:0> def foo=(bar) irb(main):002:1> p
I have a script that does various things and access parameters using sys.argv but
For the following simple wxPython snippets: import sys import wx class MyApp(wx.App): def OnInit(self):
Say I have a module with the following: def main(): pass if __name__ ==
I have this class: class View(object): def main_page(self, extra_placeholders = None): file = '/media/Shared/sites/www/subdomains/pypular/static/layout.tmpl'
Consider the following: irb(main):001:0> class A irb(main):002:1> def initialize irb(main):003:2> @string = my string
def self.get(server) return unless server server = server.to_s if klass = @handlers[server] obj =
In a script I'm trying to import the main module from another script with
def foo (): x = re.compile('^abc') foo2(x) def foo2(x): How do I get x
def update @album = Album.find(params[:id]) if @album.update_attributes(params[:album]) redirect_to(:action=>'list') else render(:action=>'edit') end end A Rails

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.