Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

Ideas?

share|improve this question
add comment

4 Answers

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

Edit:
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
add comment

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
add comment

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
add comment

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
add comment

Your Answer

 
discard

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.