User Tools

Site Tools


bash:run_a_program_or_script:run_a_program_in_the_background

BASH - Run a program or script - Run a program in the background

By default, programs usually run in the foreground. This prevents another application being run in the same terminal at the same time.

To have this first program run in the background:

Pause the running process by hitting CTRL-Z:

CTRL-Z

This will pause the running process.

returns:

^Z
[1]+  Stopped                 sudo ls -R /

NOTE: From here you can manipulate it with:

  • fg: Move to foreground
  • bg: Run in background.
  • kill: Kill the process.

Restart the job in the background

bg

returns:

[1]+ sudo ls -R / &

NOTE: The command is now running in the background.

We can now run the other application.


Bring the first program out of the background

fg

Stop the process

Press the control key and hit c.

CTRL-C
bash/run_a_program_or_script/run_a_program_in_the_background.txt · Last modified: 2021/02/04 14:17 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki