Linux: Start Command In Background

Linux: Start Command In Background

To start a command in the background on a Linux system, you can use the & operator. When a command is run in the background, it will execute independently of the current shell, and you will be able to continue using the terminal or console while the command is running.

Here's an example of how to start a command in the background:

$ <command> &
Source:ww‮tual.w‬turi.com

Replace <command> with the command that you want to run.

For example, to start the sleep command in the background:

$ sleep 60 &

This will run the sleep command in the background, causing the system to sleep for 60 seconds.

You can also use the nohup command to run a command in the background, even if you close the terminal or log out of the system. nohup stands for "no hangup," and it prevents the command from being terminated when the terminal is closed.

Here's an example of how to use nohup to run a command in the background:

$ nohup <command> &

Replace <command> with the command that you want to run.

For example, to run the sleep command in the background using nohup:

$ nohup sleep 60 &

Note: The specific options and syntax for these commands may vary depending on your Linux distribution and version. Consult the man pages or documentation for your system for more information.

Created Time:2017-10-30 10:17:47  Author:lautturi