Domain Expiration Check Shell Script

I have already written a shell script to check/monitor domain renew / expiration date here. Now I have modified matty’s domain-check script to support additional C/TLDs .in, .biz, .org and .info domains. I’ve also added 5 seconds delay to avoid whois server rejecting the query. This script checks to see if a domain has expired. It can be run in interactive and batch mode and provides facilities to alarm if a domain is about to expire in advance.

Sample usage

Display expiration date and registrar for domain:
$ domain-check-2 -d {domain-name}
$ domain-check-2 -d

Sample outputs:

Domain                              Registrar         Status   Expires     Days Left
----------------------------------- ----------------- -------- ----------- ---------                            et4India (R7-AFIN Valid    28-Oct-2009   799  

You can also get an email if going to expire in 30 days
$ domain-check-2 -a -d -q -x 30 -e
However most killer feature is you can read list of domain names from a file such as mydomains.txt (list each domain on a new line):
$ domain-check-2 -a -f mydomains.txt -q -x 30 -e
$ domain-check-2 -f mydomains.txt
Sample outputs:

Domain                              Registrar         Status   Expires     Days Left
----------------------------------- ----------------- -------- ----------- ---------                            et4India (R7-AFIN Valid    28-Oct-2009   799              , Inc.  Valid    13-Aug-2009   723                       MONIKER ONLINE SE Valid    18-aug-2010   1093                                         Valid    30-Jun-2009   679              Inc. ( Valid    26-Jun-2009   675                        GODADDY.COM, INC. Valid    11-dec-2009   843  

You can setup cron job as follows to get an email notification about domain expiration:
@daily /path/to/script -f /path/to/mydomains.txt -e

Quick installation

Use wget command to download and install domain-check script:
$ wget
$ wget
$ sudo mv /usr/local/bin/
$ sudo chmod +x /usr/local/bin/
$ /usr/local/bin/domain-check -d

Getting help about the script

$ -h
Sample outputs:

Usage: [ -e email ] [ -x expir_days ] [ -q ] [ -a ] [ -h ]
          {[ -d domain_namee ]} || { -f domainfile}
  -a               : Send a warning message through email 
  -d domain        : Domain to analyze (interactive mode)
  -e email address : Email address to send expiration notices
  -f domain file   : File with a list of domains
  -h               : Print this screen
  -s whois server  : Whois sever to query for information
  -q               : Don't print anything on the console
  -x days          : Domain expiration interval (eg. if domain_date < days)

Make sure your run domain-check-2 script using a Unix/Linux cron jobs. For more info and PR see my github page.

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
103 comments… add one
  • Junnes Sep 12, 2017 @ 15:43


    Actually domains doesn’t work.
    Does anyone knows how to fix it ?

  • Stefan Weichinger Aug 28, 2017 @ 12:48

    .at doesn’t work either.
    Tried to write a patch but noticed that server “” does not return an expiry date.

  • KP Aug 26, 2017 @ 14:51

    I’ve noticed that the support for *.link and *.cafe is missing, and I’ve added it to my own script. Is there a github repository that I can push this to in order to help others?

  • Dan Aug 20, 2017 @ 17:54

    Unbale to get the hack to work. I’ve added the line as follows but its throwing an error that it doesn’t understand +%d-%b-%Y`

    Can anyone help?

    #echo $DOMAINDATE # debug
    # Whois data should be in the following format: “13-feb-2006″
    set — ${DOMAINDATE}
    MONTH=$(getmonth ${2})
    DOMAINDATE=`date -d ${DOMAINDATE} +%d-%b-%Y`

  • Thatguy Aug 13, 2017 @ 18:47

    Seems my previous post got truncated…

    Looks like whois is dates are being returned in the format:
    Registry Expiry Date: 2019-06-17T04:00:00Z

    Where as the script comments are expecting in this format:
    # Whois data should be in the following format: “13-feb-2006”

    script will need a retweak to calculate on the new format.

    Dirty hack:
    add line “DOMAINDATE=`date -d ${DOMAINDATE} +%d-%b-%Y`”

    #echo $DOMAINDATE # debug
    # Whois data should be in the following format: “13-feb-2006”
    DOMAINDATE=`date -d ${DOMAINDATE} +%d-%b-%Y`

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.