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=&#8221;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&#8221;
echo &#8221;Checking the sites for Links&#8221;
echo $websites|tr &#8217; &#8217; &#8217;\n&#8217;
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 &#8221;Link not found on $i&#8221;
fi
done

Then make a crontab entry like this:

40 08 * *  * (echo &#8221;Subject: Link verification on affiliate sites @ `date`&#8221;;/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&#8217;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">


author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it