Running a linux application (process) in the background

by admin on July 23, 2009 · 0 comments

Say, for example, you have an application called DoStuff. For sake of argument lets say that this app scans a directory and searches for files called “steve.txt”. Because you have a large directory structure, this can take a number of minutes to complete.

You can run this from a console by simply typing its name:

steve@steve-desktop:~$ DoStuff

By doing this you will have to wait until the application has finished before you have control of this console again.

If you want to run this application in the background then you can simply add a “&” to the end of the command:

steve@steve-desktop:~$ DoStuff &

DoStuff now runs in a background process and you have not blocked your console. Of course, you could always open multiple console windows but that quickly clutters the screen up if you have too many.

You will notice that once your background process has finished running DoStuff it will print a status message to the console it was run from. Something along the lines of:

[1]+  Exit 1                  DoStuff

This is a notification that the process has finished – you will see an error message if DoStuff terminated with an error

Next post: