An Entrepreneur, Coach, IT Consultant, Strategic Adviser, and a Traveler craving to explore and contribute to forming a better society.

Friday, January 23, 2009

Sending Mail Automatically After Completion of a CRON Job

No comments :
Keywords: Shell Scripting, Linux, Unix, CRON, Scheduled Tasks, Unix Administration, Administration

Sending Mail Automatically After completion of a CRON Job

Question:

I have scheduled a job in cron. I want a mail to be sent automatically to the administrator(of course, me), once the job is completed. How can I do that?

Answer:

1. Create a script file (.sh)
2. Modify the following statements and insert it into the file

#!/bin/sh

run_the_task_file.sh && echo "Hi Administrator,

`date '+%d-%B-%Y %X'`

#TASK NAME#

#TASK Description#

#TASK Completion Status#

Regards,
Your Name(Automatic Mail)" | mail -s "TaskName Completed Successfully on `date '+%d-%B-%Y %X'`" mailid@maildomain.com

3. Add the new file to your cron task scheduler :-)
4. Thats it 

Keywords: Shell Scripting, Linux, Unix, CRON, Scheduled Tasks, Unix Administration, Administration

Featured Blog Topics:

No comments :