Checking the links to your site (from affiliates) using cron and bash script.
2010-05-27
281 words
2 mins read
If you have some affiliate links and are concerned about their presence then you can setup <a class="zem_slink freebase/guid/9202a8c04000641f80000000045c9c5b" title="Cron" rel="wikipedia" href="http://en.wikipedia.org/wiki/Cron">cron to check the links for you regularly. For this you need a very simple script (as below) and a cron entry (example further down).
#!/bin/bash –
#===============================================================================# FILE: checklinks.sh
# USAGE: ./checklinks.sh
# DESCRIPTION: Check if the links exists on affiliate sites
# OPTIONS: —
# REQUIREMENTS: —
# BUGS: —
# NOTES: —
# AUTHOR: <a class="zem_slink" title="Amit Agarwal" rel="homepage" href="http://amit-agarwal.co.in">Amit Agarwal (AKA), amit.agarwal@amit-agarwal.co.in
# COMPANY: Individual
# VERSION: 1.0
# CREATED: 04/07/2010 08:19:29 AM IST
# REVISION: —
#===============================================================================websites=”space seperated <a class="zem_slink freebase/en/website" title="Website" rel="wikipedia" href="http://en.wikipedia.org/wiki/Website">website address like http://amit-agarwal.co.in http://blog.amit-agarwal.co.in”
echo ”Checking the sites for Links”
echo $websites|tr ’ ’ ’\n’
echo
echo
for i in $websites
do
curl -s $i |grep amit-agarwal.co.in > <a class="zem_slink freebase/en/dev_null" title="/dev/null" rel="wikipedia" href="http://en.wikipedia.org/wiki//dev/null">/dev/null
if [ $? != 0 ]
then
echo ”Link not found on $i”
fi
done
Then make a crontab entry like this:
40 08 * * * (echo ”Subject: Link verification on affiliate sites @ `date`”;
/checklinks.sh) |/usr/sbin/sendmail <h6 class="zemanta-related-title">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://blog.amit-agarwal.co.in/2010/03/08/email-web-statistics-from-the-hosted-website-using-awstats-page/">Email web statistics from the hosted website using awstats page. (amit-agarwal.co.in) <li class="zemanta-article-ul-li"><a href="http://on10.net/blogs/sarahintampa/Bings-Wallpaper-Search-Feature/">Bing’s Wallpaper Search Feature (on10.net) <li class="zemanta-article-ul-li"><a href="http://blog.amit-agarwal.co.in/2010/02/10/bash-script-with-sql-to-get-the-number-of-records-from-multiple-tables/">bash script with sql to get the number of records from multiple tables. (amit-agarwal.co.in) <li class="zemanta-article-ul-li"><a href="http://lifehacker.com/5483992/variably-safe-for-work-previews-questionable-links-keeps-you-out-of-trouble">Variably Safe For Work Previews Questionable Links, Keeps You Out of Trouble (lifehacker.com) <li class="zemanta-article-ul-li"><a href="http://blog.amit-agarwal.co.in/2010/04/07/email-with-templates-with-variables-from-the-command-line-with-sendmail-or-any-other-mta/">email with templates (with variables) from the command line with sendmail or any other MTA. (amit-agarwal.co.in) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/a5be6337-90ec-447d-b44c-ee5c4a2128c2/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b92.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">
Related Articles:
- 2010/05/20 Startup animation and theme for Fedora 12 onwards.
- 2010/05/19 Mirror or download a website with a tool much better than wget
- 2010/05/17 Script to download all the related videos from youtube with youtube-dl
- 2010/03/08 Email web statistics from the hosted website using awstats page.
- 2010/05/27 vim - get mappings from the help tex files available with the scripts.