How configure crontab in ESXi to schedule a job every 5 min
For scheduling a command or script every 5 min in ESXi we need to edit following file
/var/spool/cron/crontabs/root
vi /var/spool/cron/crontabs/root
#min hour day mon dow command 1 1 * * * /sbin/tmpwatch.py 1 * * * * /sbin/auto-backup.sh 0 * * * * /usr/lib/vmware/vmksummary/log-heartbeat.py */5 * * * * /sbin/hostd-probe ++group=host/vim/vmvisor/hostd-probe 00 1 * * * localcli storage core device purge */2 * * * * /usr/lib/vmware/vsan/bin/vsanObserver.sh
Now add your script or command save save exit
wq!
Note (*/5 ) means every 5 min execute the command or script .
Now cron will start working but all it’s setting will be lost after the reboot
Now, add a command to /etc/rc.local to re-generate the cron job when ESX/ESXi reboots