Skip to content

Instantly share code, notes, and snippets.

@saintmalik
Last active August 21, 2021 18:34
Show Gist options
  • Save saintmalik/327b87bbb61f8b2f9207ce815be534b8 to your computer and use it in GitHub Desktop.
Save saintmalik/327b87bbb61f8b2f9207ce815be534b8 to your computer and use it in GitHub Desktop.
How to Monitor Website Uptime Using Bash Script, VPS Server and Slack

How to Check Site Downtime Using Bash and Cron Job

Get a Ubuntu VPS Server, use this link, so you get free $100 Digital Ocean credit.

Install Golang on your Ubuntu VPS Server: https://linuxize.com/post/how-to-install-go-on-ubuntu-20-04/

Install notify; https://github.com/projectdiscovery/notify#installation-instructions

Source Code for Uptime Checker Bash Script: https://gist.github.com/saintmalik/b10aa014a8f37365cadaf9e86db8a612

chmod +x uptime-check.sh

Enter all the URLS you want to monitor into your "urls.txt" file

now open your crontab using: crontab -e

enter this intto your cron:

* * * * * /home/YOURUSERNAME/uptime-check.sh | /home/YOURUSERNAME/go/bin/notify -silent >> /home/YOURUSERNAME/uptime-check.log 2&1

NOTE: You must have set your slack, telegram or discord webhook in your notify config, you can find it here /home/YOURUSERNAME/.config/notify/notify.conf

If you are looking for how to create slack webhook

for discord webhook

for telegram

If you use slack you should get errors like this if your site is down: Screenshot 2021-08-21 at 6 21 00 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment