Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put a Python script in the background without pythonw.exe?

I'm fairly new to Python and I have a python script that I would like to ultimately convert to a Windows executable (which I already know how to do). Is there a way I can write something in the script that would make it run as a background process in Windows instead of being visible in the foreground?

like image 615
Liam Avatar asked Aug 28 '17 04:08

Liam


People also ask

How do I run a Python script in the background without terminal?

The easiest way of running a python script to run in the background is to use cronjob feature (in macOS and Linux). In windows, we can use Windows Task Scheduler. You can then give the path of your python script file to run at a specific time by giving the time particulars.

How do I run a Python function in the background?

We can configure a new daemon thread to execute a custom function that will perform a long-running task, such as monitor a resource or data. For example we might define a new function named background_task(). Then, we can configure a new threading. Thread instance to execute this function via the “target” argument.

What is the difference between Python exe and Pythonw exe?

python.exe is associated with . py files and opens and runs in a terminal window. pythonw.exe is associated with . pyw files and does not open the terminal.


1 Answers

You can always run a Windows program in the background using

START /B program

See this post for more information.

like image 110
Shai Avatar answered Oct 12 '22 14:10

Shai