Gathering esxtop performance data using cronjobs
search cancel

Gathering esxtop performance data using cronjobs


Article ID: 323138


Updated On:


VMware vSphere ESXi


This article provides steps for setting up a scheduled cron job to run esxtop in batch mode. The esxtop utility redirects the output to a .csv file.


VMware ESXi 4.1.x Embedded
VMware ESX Server 3.0.x
VMware ESXi 3.5.x Embedded
VMware vSphere ESXi 5.5
VMware vSphere ESXi 5.1
VMware vSphere ESXi 6.5
VMware ESXi 3.5.x Installable
VMware vSphere ESXi 8.0
VMware vSphere ESXi 7.0.0
VMware ESXi 4.0.x Installable
VMware ESX 4.1.x
VMware vSphere ESXi 5.0
VMware ESX Server 3.5.x
VMware vSphere ESXi 6.7
VMware ESXi 4.0.x Embedded
VMware ESXi 4.1.x Installable
VMware vSphere ESXi 6.0
VMware ESX 4.0.x


You need to edit the crontab configuration file to create scheduled tasks on ESXi/ESX. For more information, see Editing configuration files in VMware ESXi and ESX (1017022) .

Before creating a scheduled task, ensure that the ESXi/ESX host's date and time are correct. For more information, see Verifying time synchronization across an ESXi/ESX host environment (1003736) .

Scheduling the task in ESXi using cron

  • First take a backup of the crontabs file to another location before editing.
cat /var/spool/cron/crontabs/root > /vmfs/volumes/<Datastore>/<folder>/crontab-$(hostname).txt
  • ​​​​​​Open the root crontab file located in /var/spool/cron/crontabs using the vi editor:
# vi /var/spool/cron/crontabs/root
  • Open To enter insert mode in vi and make changes to the file press "i"
  1. To start esxtop at the desired time, append the crontab file with the esxtop command using the syntax explained below:
Crontab Syntax
Minutes  Hour(24 hour format)   Date   Month  Day_of_Week   /usr/sbin/esxtop -b -d ## -n #### > path/name-of-the-file.csv
-b : Signifies batch mode
-d : Sampling Frequency in seconds
-n : Total number of samples.
For example, to collect the esxtop data in batch mode every night regardless of date, month or day of week at 2:20 am with frequency of sampling set to 5 seconds for 180 samples, while saving the collected data as "batch.csv" on your VMFS datastore "datastore1", the entry in crontabs/root will have to look like this:
20 2 *  *  * /usr/sbin/esxtop -b -d 5 -n 180 > /vmfs/volumes/datastore1/esxtop-batch.csv
The above command generates 15 minutes (5 x 180 seconds) worth of data for analysis.

Scheduling a rolling ESXtop using cron.

In the event of a collecting performance data where it is difficult to collect or predict when an issue may occur you may be able to set a rolling collection of performance data.

The cron job command in the code block below will place a place a mark the logs at the start of the performance data collection. Below is an example of what you may see in the vmkernel:
xxx-xx-xxTxx:xx:xxZ esxcfg-syslog[2233321]: mark: ESXTOP-CRONJOB-xxxx-xx-xxTxx:xx.csv

While collecting a rolling 15 minutes of performance data into individual files on the specified datastore.
You may notice that the files are marked by the time when we start the collection and cover the proceeding 15 minutes.

NOTE: This operation will create many files and will continue to consume space if not continuously monitored please remove the old file that do not cover the time in question and select the files with the appropriate date and time that could cover the time of interest:
*/16  *  *  *  *  localcli system syslog mark --message=ESXTOP-CRONJOB-$(date +"%FT%H:%M").csv;esxtop -ba -d 5 -n 180 >/vmfs/volumes/datastore1/folder/esxtop-$(hostname)-$(date +"%FT%H:%M").csv


Saving the file crontab file once changes have been made:

  1. Save the file.
    Note: By default, this file is read-only. However, you can write changes to the file using pressing "Esc" ":" followed by "wq!" key combination in the vi editor.
  2. To apply the new cron schedule, you will have to restart crond. Run this command to determine the process ID of the crond process:

    # cat /var/run/

    You see output similar to:


    Where 1234 is the Process ID of the crond process.
  3. Run this command to stop and restart the crond process:

    # kill -HUP 1234
  4. In order to restart the crond process use this command:
# /usr/lib/vmware/busybox/bin/busybox crond

As soon as these changes have been made, esxtop will start at the next scheduled time.
Note: The configuration changes on ESXi do not persist across reboots. To revert the change without rebooting, remove the esxtop line from the crontab file and kill the crond process and restart the crond process again.

Additional Information

Verifying time synchronization across an ESX/ESXi host environment
Using syslog log markers from the ESXi command line (2146535)
Exporting esxtop performance data as a CSV file and manipulating it from the command-line
Editing configuration files in VMware ESXi and ESX
Using Tech Support Mode in ESXi 4.1, ESXi 5.x, and ESXi 6.x
crontab を使用して指定した時刻に esxtop パフォーマンス データを収集する
使用 crontab 在特定时间收集 esxtop 性能数据