1834711 Members
2564 Online
110069 Solutions
New Discussion

Re: Script-mail hourly

 
wish_1
Frequent Advisor

Script-mail hourly

Dear Friends,

I am at one of the date centers with 5 servers of which I have to send the hourly date,uptime, sar 5 5,df -h, ./top -d 2 ---- following scripts output ------

$ more script
echo DATE
date >> sar_e
echo UPTIME >> sar_e
uptime >> sar_e
echo SAR >> sar_e
sar 5 5 >> sar_e
echo "Disk Utilization" >> sar_e
df -h >> sar_e
echo "Top" >> sar_e
./top -d 2 >> sar_e

to my bosses. Can I config. for respective 5 server so that the mail is send by it self on hourly bases betwenn 9 am to 5 pm.

Pl tell me how to config. the same

thanks in adv.

regards
wish
5 REPLIES 5
RAC_1
Honored Contributor

Re: Script-mail hourly

Schedule the script through cron. you can also enable ssh/remsh access to all servers and send just one email for all five servers.

Cron cntry would look like follows.

0 9,10,11,12,13,14,15,16,17 * * * "your_scipt"

There is no substitute to HARDWORK
Pete Randall
Outstanding Contributor

Re: Script-mail hourly

It sounds like you simply need a crontab entry to invoke your script on an hourly basis between 9am and 5pm:

00 9-17 * * 1-5 /your_script


Pete

Pete
Peter Godron
Honored Contributor

Re: Script-mail hourly

Hi,
create a command file and call from cron:
00 9-17 * * * /whatever/command
The last line of the command script should be something like:
mail -s"Hourly update `date +%H:%M" boss-email < sar_e

Antonio Cardoso_1
Trusted Contributor

Re: Script-mail hourly

while using cron as suggested above, remember that script will be executed outside your environment.
You may have to update your script to initialize PATH (or other env variable) variable or use full absolute path for any command used in your script.
Arunvijai_4
Honored Contributor

Re: Script-mail hourly

Hi Wish,

You can use the following,

Crontab syntax :-
A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)

00 9-17 * * * /
-Arun
"A ship in the harbor is safe, but that is not what ships are built for"