How to get email notification when cron is completed

This tutorial describes about how to get email notification when cron is completed.



My Scenario:-We are running Database server in Linux environment recent days scheduler(Cron) is not running properly. So i decided to configure email alert when cron is completed it automatically triggered email to our IT-Group from Linux box.  

Edit the crontab by using the below command:-
[root@techlanda.com~]# crontab -e

Here is cron script:- 
30 23 * * * mysqldump -u root ITManagement> /home/sqlbac/ITManagement_Dailybackup.sql
Email notification script:- 
echo -e "Hello,\n\tMYSQL Backup has been sucessfully taken."   "\n\n Note:This is an auto-generated email from Linux server. Please do not reply to this email.\nThanks,\nRanjit"|mail -s "ITManagement MYSQL Backup" -c cc@yourdomain.com -b bcc@yourdomain.com  to1@yourdomain.com to2@yourdomain.com to3@yourdomain.com to4@yourdomain.com -- -f FromSender@yourdomain.com

Syntax:- [YOUR CRON JOB] && [MAIL FUNCTION]

Example:-  Paste the below script in the crontab:-

30 23 * * * mysqldump -u root ITManagement> /home/sqlback/ITManagement_Dailybackup.sql && echo -e "Hello,\n\tMYSQL Backup has been sucessfully taken."   "\n\n Note:This is an auto-generated email from Linux server. Please do not reply to this email.\nThanks,\nRanjit"|mail -s "ITManagement MYSQL Backup" -c cc@yourdomain.com -b bcc@yourdomain.com  to1@yourdomain.com to2@yourdomain.com to3@yourdomain.com to4@yourdomain.com -- -f FromSender@yourdomain.com

save the configuration using :wq! or abort :q!

Apply changes we must restart the cron service:-
 [root@techlanda.com ~]# /etc/init.d/crond restart

                                or
[root@techlanda.com ~]# service crond restart


Result:-

Techlanda
Cron email notification















I hope you  this information is useful for you. Please forgive any typos or incomplete sentences.