Find the answer to your Linux question:
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.
  1. #1
    Just 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.

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Hi,

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

    Code:
    ab -n 1000 -c 100 www.example.com/dashboard > /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 ~/php-script.sh) that also checks the time, e.g.:

    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
    Make the script executable:
    Code:
    chmod +x ~/php-script.sh
    The run it once, to make sure it runs:
    Code:
    ~/php-script.sh
    It should generate the date-specific log mentioned in the script.

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

    Code:
    crontab -e
    this will open an editor (usually vi, but varies). then put something like this:
    Code:
    # command is run every 30 min
    */30 * * * * ~/php-script.sh > /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
    Just Joined!
    Join Date
    Jan 2007
    Posts
    9
    This is very helpful. Thanks a lot.

Posting Permissions

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