Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I want to run Apache benchmark but while it's running, I need to run htop to see the memory and CPU usage. How can I do that? Putty (My ssh client) won't let me type in a command until ab is done running.


share|improve this question
up vote 2 down vote accepted

You can do this in the same way that you would with a local shell, using job control. For example:

time ssh localhost 'bash -c "sleep 5 & sleep 6 &"'
... 0.00s user 0.01s system 0% cpu 6.187 total

Oh, you just want to do it on from a terminal session. You just use job control by putting & after the command, for example: benchmark & and then htop. This makes the job run in the background. You can then see which jobs are running with the jobs command and bring it back to the foreground with fg %1 where 1 is the number of the job.

share|improve this answer
Thanks. That's working (the & sign). Is there a way to stop ab from producing output (just running)? Otherwise, it just screws up the layout of htop. – Matthew Jun 10 '10 at 18:31
You probably just want to redirect the normal output (not error output) to a file or /dev/null with something like ls -l >/dev/null & – Kyle Brandt Jun 10 '10 at 19:20
bash -c is not necessary; ssh already executes commands using the user's default shell. ssh <host> 'command1 & command2' is sufficient. – grawity Jun 10 '10 at 20:30

There are many solutions (run benchmark as background job), but the best solution is to use screen. It's "window manager" for console. You can create many windows, switch between them and even detach current session. It's a very powerful tool.

share|improve this answer

GNU Screen is a great application for running multiple processes (windows) inside of one SSH session. It must reside on the machine you connected to (server).

share|improve this answer
Doesn't have to be on the client machine. I log into servers and run screen from the server all the time. If fact, that is one of it's ideal uses because if you get disconnected everything keeps running and you can reattach it. – Kyle Brandt Jun 10 '10 at 18:29
Sorry, I wrote that too quickly (corrected). Screen is great for resuming sessions, it's a must for IRC. – cdated Jun 10 '10 at 19:52

Sometimes, especially for things that take some time to run, it might be better to simply open two SSH sessions. With the windows sitting side by side it's easy to monitor just what's happening. I tend to do this a lot when I'm tailing log files while testing things.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.