-
1. Re: how to create a cron job in esxi 5.5 to reclaim space in a thin provisioned storage
MKguy Oct 13, 2016 2:53 AM (in response to athrunn0510)Edit the crontab in /var/spool/cron/crontabs/root by adding your command line like:
30 1 * * * esxcli storage vmfs unmap --volume-label=volume_label
The above example runs the command every day at 01:30 AM. You may want to adjust the time to run it at a different hour depending on when your storage load is typically lowest.
After editing the crontab you also need to kill and restart the crond process, which you can do like this:
# kill -HUP $(cat /var/run/crond.pid)
# /usr/lib/vmware/busybox/bin/busybox crond
Basically you can just follow the instructions here:
Gathering esxtop performance data at specific times using crontab (1033346) | VMware KB
Note however that modifications of the crontab do not survive a reboot, but you can inject commands to run at boot via /etc/rc.local.d/local.sh like this:
https://www.stephen-scotter.net/computers/virtualisation/ghettovbb-esxi-5-5-crontab
-
2. Re: how to create a cron job in esxi 5.5 to reclaim space in a thin provisioned storage
athrunn0510 Oct 13, 2016 7:19 AM (in response to MKguy)Thank You MKguy!
BTW, how can I check that the job is running during its schedule? thru esxtop?
Can i have simultaneous volume unmap during one (1) schedule cron?
ex) 30 1 * * * esxcli storage vmfs unmap --volume-label=volume_label1
30 1 * * * esxcli storage vmfs unmap --volume-label=volume_label2
Also, what is the specific command from ghettoVCB.sh that will make the cron job persistent across reboot.
Thanks!
-
3. Re: how to create a cron job in esxi 5.5 to reclaim space in a thin provisioned storage
athrunn0510 Oct 13, 2016 7:20 AM (in response to MKguy)Thank You MKguy!
BTW, how can I check that the job is running during its schedule? thru esxtop?
Can i have simultaneous volume unmap during one (1) schedule cron?
ex) 30 1 * * * esxcli storage vmfs unmap --volume-label=volume_label1
30 1 * * * esxcli storage vmfs unmap --volume-label=volume_label2
Also, what is the specific command from ghettoVCB.sh that will make the cron job persistent across reboot.
Thanks!
-
4. Re: how to create a cron job in esxi 5.5 to reclaim space in a thin provisioned storage
MKguy Oct 13, 2016 10:05 AM (in response to athrunn0510)BTW, how can I check that the job is running during its schedule? thru esxtop?
Whenever a cron job is started, it will be logged in /var/log/syslog.log, so you could grep for cron or the esxcli keyword it:
# grep cron /var/log/syslog.log
To check whether it's currently still running, you can check the running processes like this:
# ps -ct | grep esxcli
# esxcli system process list | grep esxcli
You can also refer to the VAAI stats in esxtop (press 'u' for storage device mode, press 'f' and add VAAI stats with 'o' removing other unneeded statistics) which should indicate DELETE commands on the storage device:
4:39:51pm up 1 day 4:33, 751 worlds, 14 VMs, 33 vCPUs; CPU load average: 0.06, 0.04, 0.04 DEVICE CLONE_RD CLONE_WR CLONE_F MBC_RD/s MBC_WR/s ATS ATSF ZERO ZERO_F MBZERO/s DELETE DELETE_F MBDEL/s mpx.vmhba32:C0:T0:L0 0 0 0 0.00 0.00 0 0 0 0 0.00 0 0 0.00 naa.6000xxxxxxxxxxx 0 0 0 0.00 0.00 44443 1 146 0 0.00 0 0 0.00 naa.6000xxxxxxxxxxx 0 0 0 0.00 0.00 49063 14 134 0 0.00 0 0 0.00
Can i have simultaneous volume unmap during one (1) schedule cron?
Yes, you can define as many cron jobs as you want but I would be very careful with running multiple simultaneous unmaps. I would at least leave an hour or more of time between them.
Also, what is the specific command from ghettoVCB.sh that will make the cron job persistent across reboot.
You need to modify the /etc/rc.local.d/local.sh file which is executed once upon every system bootup and make it insert the cron jobs and restart the serivce. Something like this would work:
#!/bin/sh # local configuration options # Note: modify at your own risk! If you do/use anything in this # script that is not part of a stable API (relying on files to be in # specific places, specific tools, specific output, etc) there is a # possibility you will end up with a broken system after patching or # upgrading. Changes are not supported unless under direction of # VMware support. # Gets the cron service pid and kill it: /bin/kill $(cat /var/run/crond.pid) # Add 2 lines to the crontab: /bin/echo "30 1 * * * esxcli storage vmfs unmap --volume-label=volume_label1" >> /var/spool/cron/crontabs/root /bin/echo "30 2 * * * esxcli storage vmfs unmap --volume-label=volume_label2" >> /var/spool/cron/crontabs/root # Start the cron service again /usr/lib/vmware/busybox/bin/busybox crond exit 0
-
5. Re: how to create a cron job in esxi 5.5 to reclaim space in a thin provisioned storage
athrunn0510 Oct 13, 2016 4:08 PM (in response to MKguy)Thank You MkGuy!
Really appreciate your response. It is very informative.
So, I won't be needing to run this script ghettoVCB.sh? right?
I just need to modify the /etc/rc.local.d/local.sh with settings below
#!/bin/sh
# local configuration options
# Note: modify at your own risk! If you do/use anything in this
# script that is not part of a stable API (relying on files to be in
# specific places, specific tools, specific output, etc) there is a
# possibility you will end up with a broken system after patching or
# upgrading. Changes are not supported unless under direction of
# VMware support.
# Gets the cron service pid and kill it:
/bin/kill $(cat /var/run/crond.pid)
# Add 2 lines to the crontab:
/bin/echo "30 1 * * * esxcli storage vmfs unmap --volume-label=volume_label1" >> /var/spool/cron/crontabs/root
/bin/echo "30 2 * * * esxcli storage vmfs unmap --volume-label=volume_label2" >> /var/spool/cron/crontabs/root
# Start the cron service again
/usr/lib/vmware/busybox/bin/busybox crond
exit 0
Are there any risks that I need to take notes editing these files
/var/spool/cron/crontabs/root
/etc/rc.local.d/local.sh
Also, is there a need to have the ESXi in maintenace mode prior to running the cron and editing the root and local.sh file?
-
6. Re: how to create a cron job in esxi 5.5 to reclaim space in a thin provisioned storage
MKguy Oct 14, 2016 2:31 AM (in response to athrunn0510)So, I won't be needing to run this script ghettoVCB.sh? right?
No, this has nothing to do with that script. I was just linking you an example where someone did the exact same thing of editing the crontab and local.sh for the same purpose and he just happened to use that script instead of your esxcli or any other command.
I just need to modify the /etc/rc.local.d/local.sh with settings below
I have written exactly what you need to do in the previous post.
Are there any risks that I need to take notes editing these files
/var/spool/cron/crontabs/root
/etc/rc.local.d/local.sh
Not if you know what you're doing do as instructed here. Note however that this is formally not supported by VMware.
Of course there is always a possibility that you can hose your system if you just put junk in them.
Also, is there a need to have the ESXi in maintenace mode prior to running the cron and editing the root and local.sh file?
No.
-
7. Re: how to create a cron job in esxi 5.5 to reclaim space in a thin provisioned storage
athrunn0510 Oct 17, 2016 7:50 PM (in response to MKguy)Thanks MKguy!
This is very helpful...