What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Bash job control lets you pause a running command, resume it in the background or foreground, inspect its job number, wait for completion, and control what happens when the shell exits. Start a batch-style command asynchronously by appending &, inspect it with jobs, suspend a foreground command with Ctrl+Z, then use bg or fg with the displayed jobspec.

long_command >output.log 2>&1 &
jobs -l
# Press Ctrl-Z on a foreground command, then:
bg %1
fg %1
wait %1

What Bash job control does

Job control is Bash’s mechanism for selectively stopping (suspending) processes and resuming them later. Bash associates a job with each pipeline and keeps those jobs in a job table. The jobs builtin displays the jobs Bash currently knows about, usually with a small job number such as 1.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A job can be a single command or a pipeline. For example, generate | sort | less is one Bash job even though it contains several processes. Job control operates on that pipeline as a unit when you use a jobspec such as %1.

Foreground and background are not merely labels in the prompt. Bash places the active terminal process group in the terminal’s foreground process group. Processes in that group can receive keyboard-generated signals such as SIGINT when you press Ctrl+C. A background process is in another process group: it cannot normally read from the controlling terminal, and a read normally causes SIGTTIN, suspending it. If the terminal’s tostop setting is enabled, a background write can cause SIGTTOU.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

Foreground and background execution compared

Behavior Foreground job Background job
Shell prompt Bash waits for the command and does not give you a prompt until it stops or exits. Bash returns the prompt immediately after starting the asynchronous job.
Terminal input Can read from the controlling terminal. Cannot normally read from the controlling terminal; a read can trigger SIGTTIN.
Keyboard signals Receives terminal-generated signals such as SIGINT. Is in a different process group and is not targeted by those keyboard-generated signals.
Job table Tracked as the current job while it runs. Listed by jobs while Bash keeps it active.
Best fit Interactive programs that need your input. Batch-like work that can run without terminal interaction.
Shell exit A stopped or running job can produce an exit warning; SIGHUP handling depends on Bash’s job bookkeeping. Use disown or disown -h when you need to change Bash’s tracking or SIGHUP behavior.

When Bash is waiting for a foreground command, Bash itself is not in the terminal’s foreground process group and therefore does not receive the keyboard-generated signals intended for that command. To stop a background process deliberately, send it SIGSTOP with Bash’s kill builtin or an appropriate external signal tool.

Run a command in the background with &

Append & to a command to make it asynchronous. Bash starts the command, prints a job number and process ID, and immediately displays a new prompt.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
long_command >output.log 2>&1 &

The redirections in this example write standard output to output.log and merge standard error into the same file. Redirecting output is important for a command that should run unattended; otherwise its output can appear in your terminal while you type. The exact job number and PID vary by shell session. A typical startup message looks like this:

[1] 25647

Here, 1 is Bash’s job number and 25647 is an example process ID. Do not assume either value will be the same in another session.

Choose background candidates carefully

  • Use the background for batch-like commands that do not need keyboard input.
  • Keep an interactive program in the foreground when it expects terminal input.
  • Redirect output and, when necessary, input explicitly before starting a long-running job.
  • Remember that a pipeline remains one Bash job even though several processes may be running inside it.

List jobs and identify the right jobspec

Run jobs to see active jobs:

jobs

For process IDs as well as job states, use:

jobs -l

Bash displays a job number, a state such as running or stopped, and the command text. The -l option adds process IDs. A jobspec begins with %:

Jobspec Meaning
%1 Job number 1.
%% or %+ The current job.
%- The previous job.
%string The job whose command begins with the supplied, unique string.
%?string The job whose command contains the supplied, unique string.

Prefix and substring forms must identify one job unambiguously. If you are unsure which job is current, run jobs and use the number it prints, %+, or %-.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Suspend a foreground command with Ctrl+Z

While a foreground process is running, press the terminal’s suspend character, typically Ctrl+Z. Bash stops the process and returns control to the shell. The command is not finished; it is in a stopped state and remains in the job table.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
interactive_or_long_command
# Press Ctrl-Z
[1]+  Stopped                 interactive_or_long_command

The exact status line depends on the command and session. Once Bash displays a prompt, decide whether to continue the stopped job in the background or return it to the foreground.

Resume a stopped job in the background with bg

Use bg followed by a jobspec:

bg %1

bg [jobspec ...] resumes each specified stopped job in the background. With no jobspec, Bash uses the current job:

bg

After bg, the process continues without occupying the terminal’s foreground process group, and Bash gives you a prompt. It can still produce output unless you redirected it when launching the command.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bring a job back to the foreground with fg

Use fg when a job needs terminal interaction or when you want to watch it directly:

fg %1

fg [jobspec] resumes the selected job in the foreground and makes it the current job. With no jobspec, it selects the current job. The return status of fg is the status of the foreground command, so a failed command can make the fg invocation return a failure status.

If the process was stopped, fg continues it before handing terminal control to it. If it was already running in the background, fg moves it into the foreground process group.

A complete stop, resume, and wait workflow

  1. Start or run a command. For unattended work, launch it with output redirection and &:
    long_command >output.log 2>&1 &
  2. Record the job identity. Note the job number Bash prints, then confirm it with jobs -l.
  3. Suspend interactive work when needed. For a foreground command, press Ctrl+Z. Bash returns a prompt and marks the job stopped.
  4. Continue without the terminal. Run bg %n, replacing n with the number shown by jobs.
  5. Inspect state. Run jobs -l again. A running job may finish and disappear from the active job table after Bash reports its completion.
  6. Return terminal control. Run fg %n when the command needs input or you want it attached to the terminal again.
  7. Wait for a result. Run wait %n to wait for that job and receive its completion status.

Wait for completion and retrieve status

The wait builtin accepts jobspecs or process IDs:

wait %1
wait 25647

When given several identifiers, wait waits for them and returns the status of the last identifier. With job control enabled, wait -f waits for termination rather than merely waiting for a status change:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
wait -f %1

Waiting is useful in scripts and at an interactive prompt when a background job must finish before you inspect its output or start a dependent step. If the job has already exited and Bash has discarded it from the active table, use the process or job information that is still available in your shell’s output and check the command’s own log or status handling.

Control or stop jobs with kill

When job control is active, Bash’s kill builtin can target a jobspec:

kill %1

To force a background process into the stopped state, send SIGSTOP explicitly:

kill -STOP %1

A stopped job can later be resumed with bg %1 or fg %1. Use the least forceful signal that accomplishes your goal, and verify the target with jobs -l before signaling it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep a job across shell exit: disown and disown -h

disown changes Bash’s bookkeeping for a job; it does not create a new session and does not redirect a program’s standard input or output. Set up redirections when launching the command if it must run without an interactive terminal.

Remove the job from Bash’s table

disown %1

This removes job 1 from Bash’s active job table. Once removed, Bash no longer manages that job as an active job, so jobs, fg, and bg cannot select it through that table.

Keep it listed but prevent Bash from sending SIGHUP

disown -h %1

disown -h leaves the job listed but marks it so Bash will not send it SIGHUP when the shell sends hangup signals during exit. This changes Bash’s treatment of the job; it does not guarantee that the application is independent of the terminal or that it will never receive another signal.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Scope options

The general form is disown [-ar] [-h] [id ...]. With no identifier, Bash operates on the current job. The -a option applies the operation to all jobs, while -r limits it to running jobs. Choose the scope deliberately, especially in a shell that has several active jobs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What happens to terminal input and signals

The terminal maintains one foreground process group. Members of that group receive keyboard-generated signals such as the interrupt signal produced by Ctrl+C. A background process is in another process group, so those keyboard signals do not target it merely because it is running in the same shell.

Background jobs are prohibited from reading the controlling terminal. A program that tries to read from standard input while in the background normally receives SIGTTIN and stops. This is why a command that prompts for a password, accepts menu choices, or otherwise expects live terminal input should generally stay in the foreground or receive input from a redirected file.

Background output is different: a job can write to the terminal unless output is redirected. If stty tostop is enabled, a background write can instead cause SIGTTOU and stop the process. Redirect noisy or unattended commands to a file when practical.

Shell-exit warnings and stopped jobs

On shell exit, Bash can warn about stopped jobs. When the checkjobs shell option is enabled, Bash can also warn about running jobs and list their statuses. These warnings are a reminder to inspect the job table before closing the shell.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before exiting, run:

jobs -l

For a job you want to finish under Bash’s supervision, use wait %n. For a job that should not receive Bash’s hangup treatment, use disown -h %n, and ensure its input and output do not depend on the terminal. If a job is stopped unintentionally, resume it with bg %n or bring it forward with fg %n before deciding whether to exit.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common job-control errors

“fg: %1: no such job” or an invalid jobspec

The number may belong to an earlier job that has finished, or the current shell may have a different job table. Run jobs, copy an active number, and retry. You can also use %+ for the current job or %- for the previous job.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

The background command stops immediately

Check whether it is trying to read from the terminal. A background read normally triggers SIGTTIN. Keep the command in the foreground or redirect standard input explicitly, then resume it with bg %n if appropriate.

The command’s output appears mixed with your typing

Background status does not suppress output. Redirect standard output and standard error when launching the command:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
long_command >output.log 2>&1 &

If the job is already running, bring it forward with fg %n and restart it with suitable redirections when that is safe for the program.

disown did not make the program independent

disown only changes Bash’s job bookkeeping and SIGHUP behavior. It does not detach standard input, standard output, or standard error from the terminal. Start the command with explicit redirections and choose a program design that does not require interactive input.

Ctrl+Z did not finish the command

Ctrl+Z is the suspend character. It stops the foreground job and returns a prompt; it does not terminate the process. Use bg %n or fg %n to continue it, or use kill %n when termination is what you intend.

A pipeline seems to have several process IDs

That is expected. Bash treats the pipeline as one job for job-control commands, while each component can have its own process ID. Use the job number with fg, bg, wait, or kill; use jobs -l when you need the individual IDs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Useful command reference

Command Purpose Important behavior
jobs [-lnprs] [jobspec] List active jobs. -l includes process IDs; job numbers and states come from the current shell.
jobs -x command [arguments] Run a command after replacing jobspecs with process-group IDs. Useful when another command expects process-group IDs rather than Bash jobspec syntax.
bg [jobspec ...] Resume stopped jobs in the background. No jobspec means the current job.
fg [jobspec] Resume or move a job to the foreground. No jobspec means the current job; its status is the foreground command’s status.
wait [jobspec or PID] Wait for completion or a state change. Returns the status of the last identifier; wait -f waits for termination when job control is enabled.
kill [signal] jobspec Send a signal to a job. Use SIGSTOP when you specifically need to force a running background process to stop.
disown [-ar] [-h] [id ...] Change Bash’s tracking and hangup treatment. Without -h, the selected job is removed; -h keeps it listed but prevents Bash from sending it SIGHUP.
suspend Pause the shell until SIGCONT. A login shell or shell without job control cannot normally be suspended; suspend -f forces it.

Practical decision guide

  • Need the prompt immediately? Append &, then inspect the job with jobs -l.
  • Need to pause what is currently running? Press Ctrl+Z.
  • Want it to continue without occupying the terminal? Run bg %n.
  • Need to interact with it again? Run fg %n.
  • Need to know when it finishes? Run wait %n or wait -f %n when termination, rather than any state change, is required.
  • Need to stop it deliberately? Verify the target with jobs -l, then use kill %n or kill -STOP %n for a forced suspension.
  • Closing the shell? Check jobs -l, redirect I/O for unattended work, and use disown or disown -h only when their specific bookkeeping and SIGHUP effects match your goal.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.