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.
easy:
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.exeprogram – 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