Scheduling Tests
Explore methods for scheduling test execution across different operating systems in performance testing contexts, including Linux and Windows approaches.
Mark
Performance Testing Expert
This post explores methods for scheduling test execution across different operating systems in performance testing contexts.
Linux Scheduling Methods
AT Command
The AT utility enables users to designate a time and a command to execute. This example schedules a JMeter test at 00:05 AM:
at 00:05 -f /path/to/jmeter-test.sh
Crontab
The CRON scheduler allows scheduled execution at specified times. This example demonstrates scheduling a JMeter test at 02:00:
# Edit crontab
crontab -e
# Add this line to run at 02:00 daily
0 2 * * * /path/to/apache-jmeter/bin/jmeter -n -t /path/to/test.jmx -l /path/to/results.jtl
Sleep Command
This approach introduces a time delay before executing a command. The demonstration shows executing a JMeter test after a 3600-second (one-hour) delay:
sleep 3600 && /path/to/apache-jmeter/bin/jmeter -n -t /path/to/test.jmx -l /path/to/results.jtl
Windows Scheduling Methods
Timeout Command
Windows offers a comparable feature using the TIMEOUT command for a time delay and a command to execute, mirroring the Linux sleep functionality:
timeout /t 3600 && jmeter -n -t test.jmx -l results.jtl
Task Scheduler
This built-in Windows tool supports scheduled task creation at specific times. This example creates a daily JMeter task scheduled for 02:00:
schtasks /create /tn "JMeter Test" /tr "C:\path\to\jmeter.bat -n -t test.jmx" /sc daily /st 02:00
Cross-Platform Alternative
Consider using Jenkins as an additional scheduling solution applicable to both operating systems for task automation including JMeter tests. Jenkins provides:
- Flexible scheduling with cron-like syntax
- Integration with version control systems
- Result reporting and trend analysis
- Distributed test execution capabilities
Further Reading
Tags: