logo

How to Run Programs in the Background Using the Batch Command 📂Programing

How to Run Programs in the Background Using the Batch Command

Code

Let’s say you want to run a program called program.

Windows

START /B program

You just need to add START /B before program1. For instance, assume you have the following files: REPL.jl, REPL.py, and REPL.bat.

  • REPL.py:
import time
while True:
    print("It's from python")
    time.sleep(1)
  • REPL.jl:
while true
    println("It's from julia")
    sleep(1)
end
  • REPL.bat:
START /B julia REPL.jl
START /B python REPL.py

The Julia and Python files are programs that output a message every second, and the batch file executes each of the files in the background. The result confirms that both programs coexist and output messages as follows.

alt text

Linux

program &

You just need to add an ampersand & after program.

Environment

  • Windows 11
  • Linux Mint 21.2 Cinnamon v5.8.4