This script checks if a cron is present on server, if not add cron entry. Then checks if there is any old hung process, if yes and its hung for more than 5 mins kill all such process and restart cron. Also checks for hung process from another way ie by checking modified time of log file created from cron if mtime is more than a value, restart cron. Log every task performed like : cron added, restarted, processes killed in a log file. Flag File is used to track events. And finally sends a mail for failure / success.
Below is how you can replicate the environment :
Make a dummy cron file and cron script by yourself. ( keep editing cron script for testing, add sleep or just print hello , etc ) Change mtime of log file manually. For sending mail, use system mail accounts ( root@server )
You must have read everything during your learning session, its all basics and was part of your learning plan, still if you don’t understand anything, you can simply google it or go through your training material again.
Point to remember : No user input or breakpoint. Use error handling at every point. Make everything verbose, Add comments for every function Use proper indentation Check it thoroughly before handing it over.