I working to improve my programming environment and now I need to have output of multiple commands (coffeescript/sass compilation and unit tests) in one console. This can be achieve concatenating commands with &
:
karma start & coffee -o js/app -cw coffee/ & sass --watch sass/:css/
but when I would like to finish work and close them and press ctrl+c
they will still work in background and I have to kill each of them manually. How can I fix this and have ability to close all those commands at once?
Currently I can only think of making a grunt task that will run multiple commands but using grunt seems to be an overkill for such a task. Are there easier/alternative ways?
(Note: You can only Display one program/task at once. Also, some programs like
apt-get
don't work properly this way.)First, add an
&
symbol to the end of the line, so the line looks like this:That puts the last program in the background too.
Then, type in
jobs
to list the programs. You'll then have an output that somewhat resembles this:To bring a program to the foreground, type
fg
followed by the number of the program. For example, to bringkarma start
to the foreground, typefg 1
. To put it back in the background, press Ctrl+Z. Repeat as required.Just kill the terminal... That'll kill all commands it's running, unless you take special precautions like
dtach
...Use
job
to list your command, you will have something like thisUse
fg 1
orfg 2
to bring back jobs in foreground.&
doesn't concatenate commands. It start one by one in the background. If it's not necessary to start the commands in the background, simply use;
instead of&
.