Skip to Content

Linux - Running background commands

Posted on

If you want to run a bash (zsh also) command in background job, just try 😁

Push & to end of this command

command &
  • You can run command in background, you can continue using your terminal.
  • When terminal session is closed, this command ends.

But, logs of command will show on your terminal 😭

Stop background command

# Run command in background
command &

# Check
jobs

# Stop it by using `disown` command
disown

disown command stop the backgroudn command before :D

Run background command without logs

command &>/dev/null &

Add &>/dev/null & will prevent the command logs.

Run background command even when terminal is off

All above commands will be off if terminal session is closed. To keep the command run in background even when terminal is off, just use nohup as this command:

nohup command &>/dev/null &

Reference

Run Bash Commands background Linux

comments powered by Disqus