Domain Expiration Check Shell Script
I've already written about a shell script to check / monitor domain renew / expiration date here. Now I’ve modified matt’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 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 theos.in domain:
domain-check-2 -d {domain-name}
$ domain-check-2 -d theos.in
Output:
Domain Registrar Status Expires Days Left ----------------------------------- ----------------- -------- ----------- --------- theos.in et4India (R7-AFIN Valid 28-Oct-2009 799
You can also get an email if theos.in going to expire in 30 days
$ domain-check-2 -a -d theos.in -q -x 30 -e vivek@nixcraft.com
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 vivek@nixcraft.com
OR
$ domain-check-2 -f mydomains.txt
Output:
Domain Registrar Status Expires Days Left ----------------------------------- ----------------- -------- ----------- --------- theos.in et4India (R7-AFIN Valid 28-Oct-2009 799 nixcraft.org oDaddy.com, Inc. Valid 13-Aug-2009 723 vivekgite.com MONIKER ONLINE SE Valid 18-aug-2010 1093 cyberciti.biz Valid 30-Jun-2009 679 nixcraft.info oDaddy.com Inc. ( Valid 26-Jun-2009 675 nixcraft.net GODADDY.COM, INC. Valid 11-dec-2009 843
Download
=> Download modified domain-check-2 script here.
Quick installation
Use wget command to download and install domain-check script:
$ wget http://www.cyberciti.biz/files/scripts/domain-check-2.txt
$ mv domain-check-2.txt domain-check
$ chmod +x domain-check
$ ./domain-check -d vivekgite.com
Make sure your run domain-check script using a cron job.
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in other helpful articles:
- Shell script to check / monitor domain renew / expiration date
- Lighttpd redirect www.domain.com requests to domain.com or vice versa
- How to: Check the bash shell script is being run by root or not
- Can I use SSL certificate for my sub domains as well?
- Join a Windows Domain From Linux / UNIX Computer Using Samba
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: cron_jobs, date_of_expiration, domain_information, domain_whois, expiration_date, grep_command, shell_script, whois_command



but… it doesnt work with things like .co.nz domains…
Nate,
You need to modify script to work with .co.nz. I’ve modified as per my requirements. Basically you need to know whois server name for all .nz domain and date format. Let me know those thing and I can tell you the rest
realy good works thanks a lot vivek
I’ve hacked the script to work somewhat with Nagios.
Does anyone want it?
Sure post the script / url / link. If you don’t have a website just email me the script
This script works much better than some of the others on the net. Thanks!
I can’t get the script to work for me. I get the following error:
-bash: domain-check: command not found
kendall,
Did you renamed the script? Did you setup executable permission? Did you run script as:
thank you for your quick responce. that fixed my problem. and the script works, but it does not flag .ca domains very well. it seems to skip a few such as beelineweb.ca
what I mean by skipped, is that is says unknown, but when I look it up manualy it showes that the domain is valid
are there any additions to the script that I can put in so it e-mails out when it finds an “unknown” domain?
Its great script. does any one know similar php script?
Mark: Would love to grab a copy of your Nagios version of script! Can you post a link or something? Thanks a bundle.
dave,
I’m not sure if mark can get your message.
# Mark Says: September 4th, 2007 at 2:50 pm
I’ve hacked the script to work somewhat with Nagios.
Does anyone want it?
email me or post the url, thanks
if date format is that then script will not work
Renewal-Date: 2008/11/20
Date-Approved: 2006/11/20
Date-Modified: 2007/10/21
give falst output, how to overcome that.
i suggest you look at the perl NET::DRI package. it can be a bit of bear to install with all of its dependencies, but once you get it working, it’s quite nice. look at their example whois.pl script.
very nice script. I noticed u accidently hardcoded awk in the code instead of ${AWK} on the line that looks at “Domain Expiration Date”. You could add switches to display other info (i.e. owner, etc…) in case one would want a more detailed report. Either way, nice and easy to use! good job!
Very…Very Very nice script… but I want something more..I’m sure you can do it. The script should also show the nameservers update date..it’ll be a good idea..isn’t it?
Regards,
Tushar
Very nice script - please give me a link or email address to obtain the nagios version of it