I want to set up a batch file or cronjob of some sort, using the linux command line, to check the availability of domain names. I will provide the list of domains to check using another file. It must then only do 30 checks per hour, and only if the domain is available, it must add that domain name to a different file. So…
- Do I have to create a batch file?
- What command must go in the batch file, that will:
- move through an existing list of domains
- check if those domains are available,
- remove that domain from the original list, and
- add the available domain to the "available" list.
- Repeat this command 20 times every hour
I know exactly how to do this with PHP and cron, but I want to know know if there is a quick way to do this using the "whois" command? It's point (2) that I am stuck on.
Best Answer
That's not too hard.
Check the list of domains
domains.txt
, and add the domain toavailable.txt
once it's found (by looking at the return value ofgrep
, which is stored in$?
).Then, remove the found domains from
domains.txt
withsed
in-place editing.Note: On BSD
sed
, you want to use the following command:You can save this script and call it from your
crontab
. Enterand then add a line like this:
This will run the script every two minutes (
*/2
). Make sure to adjust the paths to the domain before.