Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to set up a mailx of report

bob the spod
Occasional Advisor

how to set up a mailx of report

Is it viable to set up a crontab script for this task.
I need to get a report which is generated from an awk script to be sent out once a day to various users.
what do you suggest I was thinking of setting up a script, then simply getting crontab to run it at a certain time
thanks for any suggestions
bob
you make me feel like dancing (gonna dance the night away!)
4 REPLIES
Robin Wakefield
Honored Contributor

Re: how to set up a mailx of report

Hi Bob,

Sounds good to me. Remember that any output generated by a cron job is mailed to the user under which the cronjob runs, so make sure you capture all output if you want to prevent this happening, or redirect to /dev/null, e.g.:

0 0 * * * yourscript >/dev/null 2>&1

I'd put all the mail commands within your script rather than on the cron line.

rgds, Robin
Steven E. Protter
Exalted Contributor

Re: how to set up a mailx of report

/scriptname 2>&1 | mailx -s "Email subject" someemail@someplace.net

stick that in cron and it will mail all output from the script in the body of the script.


attached, production mailfile script will let you email a file(report output to disk) as an attachement to anyone you want.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com

Re: how to set up a mailx of report

Hi Bob,
Another way of doing it if you don't want all the output from the cron job mailed:
scriptname >2&1
.
.
.
in your script:
report > report.txt
elm -s"subject" whoever@wherever.com
hth

Randy
Do it as long as you love it!
Sridhar Bhaskarla
Honored Contributor

Re: how to set up a mailx of report

Hi Bob,

Since you are going to send it to multiple users, make your script look like

//

USERS="user1@yourdomain.com user2@yourdomain.com user3@yourdomain.com"

your_awkscript

cat report |mailx -s "Awk report" $USERS

//

Then put it in the cronjob as mentioned by others.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try