Results 1 to 3 of 3
Hi,
I want to set run test on cron job for php system.
Actually format is > php_test_<page name>_<date>_<time>.txt is after i run command for each page. Eg:
ab -n ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 11-12-2012 #1Just Joined!
- Join Date
- Jan 2007
- Posts
- 9
Php Benchmark
Hi,
I want to set run test on cron job for php system.
Actually format is > php_test_<page name>_<date>_<time>.txt is after i run command for each page. Eg:
ab -n 1000 -c 100 www dot exampledot com / dashboard][/code]
I have many page to test like search page, login page. More than 50 page need to test.
And it will generate report as php_test_dashboard_12122012_0930.txt. This is what i want to do. The date and time will replace each everyday..
I want put this command in cron job and run every day begin at 9AM and will repeat every 30 minute until it end at 6PM.
I think it maybe required some shell script to achieve it. But i'm not expert with shell script. Please assist me.
Thanks.
- 11-12-2012 #2Trusted Penguin
- Join Date
- May 2011
- Posts
- 3,696
Hi,
First of all, figure out your ab command to run. Here is an example, you can try it:
then when you are satisfied, put it in a script (we'll call it ~/php-script.sh) that also checks the time, e.g.:Code:ab -n 1000 -c 100 www.example.com/dashboard > /tmp/php_test_dashboard_$(date +%Y%m%d_%H%S) 2>&1
Make the script executable:Code:#!/bin/bash if [ $(date +%k) -ge 9 -a $(date +%k) -le 18 ]; then ab -n 1000 -c 100 www.example.com/dashboard > /tmp/php_test_dashboard_$(date +%Y%m%d_%H%S) 2>&1 else echo not time to run fi
The run it once, to make sure it runs:Code:chmod +x ~/php-script.sh
It should generate the date-specific log mentioned in the script.Code:~/php-script.sh
Then create a cronjob as a regular user using this command:
this will open an editor (usually vi, but varies). then put something like this:Code:crontab -e
then save and quit the file. no need to restart cron - it should pick up the new job the next minute. then start watching for those logs to appear. if they don't, check the log file /tmp/php-cronjob.log for output. You can also look in the cron log itself, usually /var/log/cron.log.Code:# command is run every 30 min */30 * * * * ~/php-script.sh > /tmp/php-cronjob.log 2>&1
This script should be executed by cron every 30 minutes. but within the script itself, the time between 9am and 6pm is checked.
- 11-12-2012 #3Just Joined!
- Join Date
- Jan 2007
- Posts
- 9
This is very helpful. Thanks a lot.


Reply With Quote
