In the first and second parts of the previous UMDS blogs, I installed UMDS and then configured and setup a repository for vSphere LCM.
This worked great, however the download and export process ended up being manual, which is less that desired. I prefer UMDS to automagically download and then export those files, so I’m going to script this and then setup a Cron (Crontab) job to automate this process.
First, let’s work on scripts for download and export. Note, I decided to break the download and export scripts into parts, for granularity and control of running them at separate times…this is just how I decided to do it.
First, I’ll create a file called umds-download.sh, then place it in the /usr/local/sbin/ because it’s the best place for script that run as root.
sudo vim umds-download.sh
Now I’ll edit that file sudo vim umds-download.sh
and add my command /usr/local/vmware-umds/bin/vmware-umds -D
which will trigger the download of the updates. I made sure to leave that uncommented, and I also added the -E (export) command but commented that out, you’ll see why in a second.
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2024/02/image-38.png?resize=348%2C172&ssl=1)
I’ll now copy that file, rename it umds-export.sh, uncomment the export function, and comment out the download function.
sudo cp umds-download.sh umds-export.sh
sudo vim umds-export.sh
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2024/02/image-39.png?resize=357%2C187&ssl=1)
Ok, that saved me some time, and now I have both a download and export scripts I can call on with crontab.
Moving on, let’s now configure a cron job.
Note that Crontab is already installed on my Ubuntu UMDS machine, so I simply need to add two cron jobs to my crontab file
crontab -e
I chose vim basic as my txt editor…and right now there are no cron jobs configured:
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2024/02/image-40.png?resize=599%2C547&ssl=1)
Here’s a link to the Cron GitLab where the Cron reference lives – lots of great info and some examples as well: https://docs.gitlab.com/ee/topics/cron/
Cron Syntax:
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2024/02/image-41.png?resize=618%2C265&ssl=1)
Let’s work first on setting up the download, I want that download to run daily. Editing the file I set the first download script to run at 12am (midnight) daily:
0 0 * * * /usr/local/sbin/umds-download.sh
And the second export script will run at 4am:
0 4 * * * /usr/local/sbin/umds-export.sh
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2024/02/image-42.png?resize=591%2C475&ssl=1)
Save the crontab file and I should be good for those scripts to run at those times.
One last double-check systemctl status cron
will give me the service status:
![](https://i0.wp.com/mikewire.com/wp-content/uploads/2024/02/image-43.png?resize=826%2C339&ssl=1)
Based on the above out put, cron is running and active, so I will monitor the job and UMDS will be downloaded and exported daily.
And that’s the end of all three parts to this vSphere setup with UMDS – if this helped you out in any way please comment below and enjoy the setup!
Leave a Reply