How to Run a JMeter Script as a Windows Cron Job

Chamindra Sulakshith

I am in need of scheduling my test such that my JMeter script automatically runs without I having to manually execute it daily. This can be accomplished via a Windows cron job but I do not know how to configure the JMeter script to run as a Windows cron job. Normally I use the command "jmeter -n -t path\filename.jmx -l path\log.csv" to execute my JMeter script via the command line so I assume if I can make this command run as a cron job it should solve the problem theoretically. So I sincerely appreciate if someone could provide the steps and details to accomplish this, thanks.

Dmitri T

You can do it using Windows Task Scheduler like

  1. Open Task Scheduler
  2. Click Action -> Create Task
  3. On "General" tab provide name
  4. On "Triggers" tab provide when you would like to run it
  5. On "Actions" tab create a new action like:

    • Program: c:\windows\system32\cmd.exe
    • Arguments: /c c:\jmeter\bin\jmeter.bat -n -t c:\jmeter\extras\Test.jmx -l c:\jmeter\bin\Test_%date:~10,4%%date:~4,2%%date:~7,2%.jtl

      JMeter Windows Scheduled Task

Change JMeter and .jmx script location to match your details.

Each time your task runs the file with current date should appear in "bin" folder of your JMeter installation like Test_20180514.jtl for today

Just in case here is exported task:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2018-05-14T07:50:02.7061254</Date>
    <Author>aldan\anonymous</Author>
    <URI>\JMeter</URI>
  </RegistrationInfo>
  <Triggers />
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-21-2873627350-121124179-3591956082-1001</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>c:\windows\system32\cmd.exe</Command>
      <Arguments>/c c:\jmeter\bin\jmeter.bat -n -t c:\jmeter\extras\Test.jmx -l c:\jmeter\bin\Test_%date:~10,4%%date:~4,2%%date:~7,2%.jtl</Arguments>
    </Exec>
  </Actions>
</Task>

Be aware that easier option could be using Jenkins to orchestrate your builds, this way you will have history, metrics, conditional failure criteria and performance trend charts.

Jenkins Performance Trend

See Continuous Integration 101: How to Run JMeter With Jenkins article for more information regarding adding performance tests under Jenkins control

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Run Cron Job on PHP Script, on localhost in Windows

From Dev

How to set a cron job to run a shell script?

From Dev

How to set a cron job to run a shell script?

From Dev

Run Rails script in cron job?

From Dev

Initialize WordPress environment in a script to be run by a cron job

From Dev

Cannot run cron job for a php script

From Dev

Cron job to run python script raises error

From Dev

Cannot run cron job for a php script

From Dev

Run a php script on localhost using cron job

From Dev

Cron job to check if PHP script is running, if not then run

From Dev

Cron job fails to run NodeJS script

From Java

How to run a cron job inside a docker container?

From Dev

How to run cron job with zend framework 2

From Dev

How to run python file in cron job

From Dev

how to run django cron job with which function

From Dev

How to run a cron job inside a docker container

From Dev

How to run a cron job as a specific user?

From Dev

Arch Linux - How to run a cron job?

From Dev

How to run cron job when network is up?

From Dev

How to run a cron job as a specific user?

From Dev

How to run a cron job to execute every minute?

From Dev

How to run a cron job using the sudo command

From Dev

How to setup cron job for a codeigniter script on server

From Dev

How to mail output of shell script as a cron job

From Dev

How to add a bash script to a cron job?

From Dev

Concerned someone will run a php script only intended for a cron job

From Dev

Python script elicits error when run in cron job but at no other time

From Dev

PHP script does not run as cron job on Ubuntu Server

From Dev

Basic Cron job to run a shell script to append date in a log, not working

Related Related

HotTag

Archive