Find the answer to your Linux question:
Results 1 to 3 of 3

Thread: Php Benchmark

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Php Benchmark


    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.


  2. #2

    First of all, figure out your ab command to run. Here is an example, you can try it:

    ab -n 1000 -c 100 > /tmp/php_test_dashboard_$(date +%Y%m%d_%H%S) 2>&1
    then when you are satisfied, put it in a script (we'll call it ~/ that also checks the time, e.g.:

    if [ $(date +%k) -ge 9 -a $(date +%k) -le 18 ]; then
      ab -n 1000 -c 100 > /tmp/php_test_dashboard_$(date +%Y%m%d_%H%S) 2>&1
      echo not time to run
    Make the script executable:
    chmod +x ~/
    The run it once, to make sure it runs:
    It should generate the date-specific log mentioned in the script.

    Then create a cronjob as a regular user using this command:

    crontab -e
    this will open an editor (usually vi, but varies). then put something like this:
    # command is run every 30 min
    */30 * * * * ~/ > /tmp/php-cronjob.log 2>&1
    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.

    This script should be executed by cron every 30 minutes. but within the script itself, the time between 9am and 6pm is checked.

  3. #3
    This is very helpful. Thanks a lot.

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts