Suppose there is a domain divya.com which has a login form. You need to login to the site every hour, to make sure that the login is working. For that the following script helps, which can be run as a cron.
##Cookies will be stored in the file cjar##
curl –cookie-jar cjar –data “firstname.lastname@example.org&password=12345” –location “http://abc.com/login/” > test2.txt
##Specify the cookie file and access another link to see if it works. If login works, you will get the code of this page, otherwise it will get redirected to the login page itself, returning a 302 status code##
curl -b cjar http://abc.com/save_org > test3.txt
CODE=$(grep -o “302 – Found” test3.txt)
if [ “$CODE” == “302 – Found” ]
echo “abc.com Login not working, please check immediately” | mail -s “Urgent Login issue” email@example.com
Execute the script for testing by giving the correct login details as well as wrong login details. If wrong details are given, check if you are getting mail to your address.
Now run the same as a cron every hour.
0 * * * * /bin/sh /root/test/abc/abc.sh