Bash – ApacheBench result to a file

apache-2.2bashbenchmarkload-testing

I would like to save ApacheBench (ab) tool on linux to a file. When I run it with -v 2 it displays some results in my ssh window. How to move these data into a file and make sure that it will not display on ssh no more? I've tried > file.txt 2>&1 but it does not work and still display data in my ssh window.

I use:

ab -n 10000 -c 200 http://mywebsite.com > file.txt 2>&1

Best Answer

Sorry nothing here but cat poo.

I do note that ab doesn't work for me unless the url has a filename or a / at the end.

Errors still go into the file, though.

Is this what you are doing? (on something other than localhost, of course)

pjb@pjb-desktop:~$ ssh localhost -l pjb
pjb@localhost's password: 
Linux pjb-desktop 2.6.31-19-server #56-Ubuntu SMP Thu Jan 28 03:40:48 UTC 2010 x86_64

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/

Last login: Sat Feb 13 04:37:53 2010 from localhost
pjb@pjb-desktop:~$ ab -v 2 -n 10000 -c 200 http://localhost/ > poo 2>&1

See, nothing.

It's all in the cat poo.

With -v2 you get lots of these in cat poo

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
INFO: POST header == 
---
GET / HTTP/1.0
Host: localhost
User-Agent: ApacheBench/2.3
Accept: */*


---
LOG: header received:
HTTP/1.1 200 OK
Date: Sat, 13 Feb 2010 12:56:45 GMT
Server: Apache/2.2.12 (Ubuntu)
Last-Modified: Tue, 17 Feb 2009 09:18:13 GMT
ETag: "120175-2d-46319c8521f40"
Accept-Ranges: bytes
Content-Length: 45
Connection: close

Otherwise without -v2 it looks like this

pjb@pjb-desktop:~$ cat poo
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.2.12
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        45 bytes

Concurrency Level:      200
Time taken for tests:   1.477 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      2980894 bytes
HTML transferred:       450135 bytes
Requests per second:    6772.68 [#/sec] (mean)
Time per request:       29.530 [ms] (mean)
Time per request:       0.148 [ms] (mean, across all concurrent requests)
Transfer rate:          1971.55 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.6      0       6
Processing:     4   17 107.8      9    1467
Waiting:        4   17 107.9      9    1467
Total:          6   18 108.1      9    1471

Percentage of the requests served within a certain time (ms)
  50%      9
  66%      9
  75%      9
  80%      9
  90%     10
  95%     11
  98%     13
  99%     15
 100%   1471 (longest request)
pjb@pjb-desktop:~$