Help on Cron job

Hi All;

I need your help in designing cron job that do health check for unix server :

i need it to execute the following command and send the result via email :

>> top
>> free -m
>> df -kh
>> mii-tool

I appreciate the help.

First create a script to collect the details in a text file and send the content for file in mail.Then add that script to cron jobs using "crontab -e " command.

An example for cpu details is given bellow

 
echo "**************Start Collecting CPU Usage***************" >> /root/alaram.txt
echo "################OUTPUT OF CPU USAGE####################" >> /root/alaram.txt
top -b -n 1 >> /root/alaram.txt
echo "################DETAILS OF CPU USAGE###################" >> /root/alaram.txt
 
 
 
 
# Send mail adding the  content of the alaram.txt

cat /root/alaram.txt | mailx -s "unix server details" yourmailid@maildomain.com

1 Like

Thanks amitranjansahu;

I'm new in unix , so can you please tell what do you mean by creating a script to collect the details in a text file and send the content for file in mail ? should i use the script that you have attached ?

yes you can use it . But you must know the basic of unix and scripting . Pls search the net and study some startup unix skill

1 Like