when i run
$ ls -R / &
although the &
(which suppose to relegate the process into the background) i end up having to sit through the entire listing of my system.
pressing CTRL+C or CTRL+Z doesn't help.
what am i doing wrong?
when i run
$ ls -R / &
although the &
(which suppose to relegate the process into the background) i end up having to sit through the entire listing of my system.
pressing CTRL+C or CTRL+Z doesn't help.
what am i doing wrong?
When you start ls -R /
in the background, the command is immediately started and control is given back to the invoking shell (your interactive shell). However, the standard output stream and the standard error stream of ls
are still connected to the terminal, so that's why you see the output of the command in the terminal.
In comments you ask a follow-up question that shows that you know that you may redirect the output of the command to /dev/null
to avoid having it stream to the terminal:
ls -R / >/dev/null 2>&1 &
The follow-up question is "Why does it show me Exit 1
when I check the job's status with jobs -l
.
You get a non-zero exit status from ls
because it did not run completely successfully. It did not, because you tried to do a recursive listing of all files on the whole system, and, presumably, some of the directories on your systems are not readable by the user that you used to run the command as. If you had not redirected the standard error stream to /dev/null
(by removing 2>&1
from the command line), you would probably have seen errors in the terminal.
kill %
, Ctrl-M, Ctrl-Q (or Ctrl-S,fg
, Ctrl-M, Ctrl-Q, Ctrl-C). – May 30 '19 at 01:16