Linux – `jobs` command doesn’t show any background processes

bashlinux

When I was in the office using my desktop, I started a script run.sh in background 4 times.

run.sh parameter1 &
run.sh parameter2 &
run.sh parameter3 &
run.sh parameter4 &

Then I came home, and opened a terminal on my laptop, ssh to the desktop in my office. When ran ps -u jack, I saw the started processes:

 3562 pts/1    00:00:00 bash
 4540 pts/2    00:00:00 bash
 4643 pts/3    00:00:00 bash
 4748 pts/4    00:00:00 bash

But when I typed jobs, I got nothing. Why I could see these four running background processes?

Btw, how can I bring them back to my current terminal, so that I can kill one of them, say run.sh parameter4 &?

Best Answer

Based on the problem statement of the question, IMHO I do not see any reason for using background or foreground. All you care is to find a process which is running in background so that you can kill it.

Run ps -ef | grep parameter3 to find processes which has parameter3 in the process name. You can adapt the grep to uniquely identify a process, given you don't have two processes with exactly same process name.

Once you have it, just do kill -9 PID and that process will be killed. So no need for bringing that process to the foreground for killing it.

Hope this helps.

Related Question