|
Some commands take a long time to finish executing. For instance, the following command stores the name of every file on your computer in the file allfiles: ls -lR / > allfiles This command can tie up your command line for a long time until it completes the job. If you don't want to wait for a command to finish, you can execute the job in the background, allowing you to enter other commands while your first command is executing. You can start the command in the background by adding an ampersand (&) to the end of the command, as follows: ls -lR / & A number is assigned to background jobs in consecutive order. The job number displays when the command is submitted and used to monitor the status of the background job. You can also send a job that is already running to the background, as follows: Ctrl-z bg The first line suspends the job. The second line starts the job in the background. You can list the jobs that are running by typing: jobs 1 ls lR / You can bring any job into the foreground with the command: fg jobnumber For example: fg 1 |
|