Questions tagged [jobs]

Job control in a shell

A job is a process or group of processes which is managed by a shell running in a terminal. The shell tracks which job is in the foreground, reports jobs' termination, can suspend and resume jobs, and can send signals to running jobs. This feature is known as job control.

146 questions
164
votes
3 answers

If you ^Z from a process, it gets "stopped". How do you switch back in?

I accidentally "stopped" my telnet process. Now I can neither "switch back" into it, nor can I kill it (it won't respond to kill 92929, where 92929 is the processid.) So, my question is, if you have a stopped process on linux command line, how do…
bobobobo
  • 1,765
  • 2
  • 11
  • 6
34
votes
4 answers

What is the purpose of delayed suspend (Ctrl-Y) in Bash?

The full portion of the Bash man page which is applicable only says: If the operating system on which bash is running supports job control, bash contains facilities to use it. Typing the suspend character (typically ^Z, Control-Z) while …
Wildcard
  • 35,316
  • 26
  • 130
  • 258
28
votes
2 answers

Why does "yes&" crash my Bash session?

"Yes, and..." is a wonderful rule-of-thumb in improvisational comedy. Not so much in the UNIX world. When I run the admittedly silly yes& command, I cannot interrupt it. The terminal crashes or gets stuck into a loop. I expect the yes process to be…
Sebastian Carlos
  • 146
  • 2
  • 12
27
votes
3 answers

How do you send command line apps directly to the background?

I already know that pressing ctrl+z stops the app, then I can send the app to background with the bg command, but that means there is a brief preiod of time that the app is stopped. How do I send the app directly to the background without stopping…
trusktr
  • 4,035
  • 7
  • 29
  • 34
27
votes
5 answers

How to plan a task to run after another already running task in bash?

I'm looking for something like command1 ; command2 i.e. how to run command2 after command1 but I'd like to plan execution of command2 when command1 is already running. It can be solved by just typing the command2 and confirming by Enter supposed…
czerny
  • 1,577
  • 3
  • 15
  • 20
24
votes
4 answers

Why do some commands 'hang' the terminal until they've finished?

Sometimes you run a program from the terminal, say, lxpanel†. The terminal won't drop you back to the prompt, it'll hang. You can press Ctrl+C to get back to the prompt, but that will kill lxpanel. However, pressing Alt+F2 (which pops up a window to…
sqram
  • 351
  • 1
  • 2
  • 6
24
votes
3 answers

How to get the Job ID?

As we know, the shell enables the user to run background processes using & at the command line's end. Each background process is identified by a job ID and, of course, by it's PID. When I'm executing a new job, the output is something like [1] 1234…
Reflection
  • 475
  • 1
  • 5
  • 8
17
votes
2 answers

What happens to background jobs after exiting the shell?

From my understanding, jobs are pipelines started from a certain shell and you can manage these jobs (fg, bg, Ctrl-Z) from within this shell. A job can consist of multiple processes/commands. My question is what happens to these jobs when the…
user2193268
  • 189
  • 1
  • 1
  • 4
13
votes
4 answers

What happens if I start too many background jobs?

I need to do some work on 700 network devices using an expect script. I can get it done sequentially, but so far the runtime is around 24 hours. This is mostly due to the time it takes to establish a connection and the delay in the output from these…
KuboMD
  • 409
  • 6
  • 16
12
votes
3 answers

Why sleep command process is still running in the background while I stopped it with CTRL-Z?

What I do is: sleep 5 and immediately CTRL-Z so when I open jobs I see: [1]+ Stopped sleep 5 next when I do fg %1 sleep process is no more running, it's done so that means it was running those 5 ( maybe 4? ) seconds while it was…
pjk
  • 323
  • 2
  • 8
12
votes
1 answer

backgrounded job keeps stopping

I am seeing some strange behavior on my RHEL6 bash prompt. I often like to execute command lines that look like ... $ ./myscript > junk 2>&1 ... then hit Ctrl-Z and then execute ... $ bg $ tail -f junk blah blah blah blah blah blah blah blah But…
Red Cricket
  • 2,183
  • 6
  • 25
  • 37
11
votes
3 answers

What happens to suspended jobs in unix?

We can issue CTRL+Z to suspend any jobs in Unix and then later on bring them back to life using fg or bg. I want to understand what happens to those jobs that are suspended like this ? Are they killed/terminated ? In other words what is the…
Geek
  • 6,548
  • 15
  • 46
  • 70
10
votes
1 answer

List all jobs in all shell sessions (not just the current shell), by current user

I know that the jobs command only shows jobs running in current shell session. Is there a bash code that will show jobs across shell sessions (for example, jobs from another terminal tab) for current user?
xxx374562
  • 292
  • 2
  • 9
9
votes
4 answers

How can I kill a job that was initiated in another shell (terminal window or tab)?

If I begin a process and background it in a terminal window (say ping google.com &), I can kill it using kill %1 (assuming it is job 1). However if I open another terminal window (or tab) the backgrounded process is not listed under jobs and…
DQdlM
  • 1,533
  • 2
  • 16
  • 21
9
votes
1 answer

Explain why watch 'jobs' does not work but watch 'ps' work?

jobs is my favorite command to see my codes which are running in the background. In order to check for them dynamically, I tend to type watch 'jobs' which does not display anything. However watch 'ps' works perfectly. I have been doing the same…
Many
  • 257
  • 1
  • 6
1
2 3
9 10