![ApacheBench 结果保存到文件](https://linux22.com/image/505896/ApacheBench%20%E7%BB%93%E6%9E%9C%E4%BF%9D%E5%AD%98%E5%88%B0%E6%96%87%E4%BB%B6.png)
我想将 Linux 上的 ApacheBench (ab) 工具保存到一个文件中。当我使用 -v 2 运行它时,它会在我的 ssh 窗口中显示一些结果。如何将这些数据移动到文件中并确保它不再显示在 ssh 上?我试过 > file.txt 2>&1,但它不起作用,仍然在我的 ssh 窗口中显示数据。
我用:
ab -n 10000 -c 200 http://mywebsite.com > file.txt 2>&1
答案1
抱歉,这里除了猫屎什么都没有。
我确实注意到,除非 url 末尾有文件名或 /,否则 ab 对我来说不起作用。
但文件中仍然会出现错误。
这是你正在做的事情吗?(当然,不是在本地主机上)
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
什么也看不见。
全都在猫屎里了。
使用 -v2 你会在猫屎中得到很多这些东西
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
否则没有 -v2 它看起来像这样
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:~$