Build Your Own Xbox Series X Stock Tracker – Part 3

by 

| April 6, 2021 | in

Xbox Series Xs are still hard to come by, so I thought, “Why not just write an application that tells me when an Xbox is in stock at Target?”

That doesn’t sound too hard.

In part 1, we created an application that would check Target’s website to see if an Xbox Series X was in stock. We checked the website using Puppeteer, which is a headless version of Chrome. This allows us to load the web page using Chrome and allowing for all the JavaScript to render.

In part 2, we modified the program to send us an SMS (text message) when the application noticed an Xbox was in stock. We accomplished this by using Twilio to send the messages.

In this third and final part, we will set up a cron job on Linux to repeatedly run the script. Running cron jobs on Linux is pretty straightforward. But first, we need a Linux box.

We will go to the Azure Portal to create a VM where we can run our script.

Go to the Azure portal https://portal.azure.com.

Then create a new resource.

You won’t need much in terms of resources. This can be a very lightweight VM.

Once you get the VM, you will log in to the VM using ssh. As part of the creation of the VM, you will create a .pem file. You will need this when logging in.

ssh -i .pem @

Once you get logged in, you need to install node and npm.

sudo apt-get install nodejs
sudo apt-get install npm

Next, you need to install Puppeteer, Twilio, and Chromium.

npm install chromium
npm install puppeteer
npm install twilio

Next, you need to copy your program.js file from your machine to the VM.

Once you have your program on the VM, I recommend running it once to ensure it works.

node program.js

If it works, it is time to add a cron job. To do that, run the crontab command.

cronttab -e

Add the following line to the cron editor.

*/5 * * * * /usr/local/bin/node /home/stocktracker/program.js

The line above will run your script every five minutes.

While this wasn’t the easiest process ever, we do now have a simple application that checks the stock of Xbox Series Xs and sends you a text message when any are available.