Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Console Foundations Processes Pausing and Resuming

why would you send jobs to the background?

For example, I understand that nano & would send nano to the background, but why would you want to do this?

Thank you in advance!

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Mark,

We need to distinguish between appending & as you describe, which sends an active job to the background (i.e., it carries on running) and pressing CTRL-z to stop (pause) an active job.

Nano is probably not the best example for illustrating why you would send something active to the background with &, since you would expect to use it interactively (i.e., in the foreground). Instead, think of something that would be typically non-interactive, like a service that runs continuously but unattended (e.g., a server) or a task that once started will take a while to finish and you want to get on with something else until it finishes without it blocking your terminal session (e.g., a large file transfer). For what it's worth, top was a bit of an odd choice to demo & since top automatically pauses when loaded with &.

However, nano might be a candidate for using CTRL-z to temporarily pause a job you're working on. You might be in the middle of typing up a file in your nano editor and you realise that you just need to check something, like 'what were the permissions on that file I was writing about?' You could quickly CTRL-z to get back out to the console (sending nano to the background), check the file, e.g. with ls -l, then type fg to go right back to where you were in nano.

Hope that helps,

Alex