General
cancel
Showing results for 
Search instead for 
Did you mean: 

how send cron job logs to gmail id?

friend_1
Occasional Advisor

how send cron job logs to gmail id?

Hi,

How to send cron job logs to gmail id from Linux server? I am using RHEL 4AS.

Please help

thanks in advance
6 REPLIES
J. Maestre
Honored Contributor

Re: how send cron job logs to gmail id?

You can:

-Create a .forward file on the home directory of the user running the cron job. That file should contain the addresses you want to forward mail to (that will forward all of that user's incoming emails, though).

-Use postfix (or similar) to compose and send mails from within the very cron job.
Steven E. Protter
Exalted Contributor

Re: how send cron job logs to gmail id?

Shalom,

In crontab

script | mail -s "Batch job" youraccount@gmail.com

Your system must be able to deliver mail directly to the Internet or be configured to a relay server.

Mail to most services like gmail requires the mail originate at a fixed IP address and the domain name in the email address and server IP address be verifiable by DNS lookup.

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
friend_1
Occasional Advisor

Re: how send cron job logs to gmail id?

Hi,

How to configuare to send logs to gmail?

Thnaks,
Steven E. Protter
Exalted Contributor

Re: how send cron job logs to gmail id?

Shalom,

Try this script.
http://www.hpux.ws/mailfile2

Alter the darned thing so it doesn't send me mail.

Again note that gmail might eat your mail if a lot of details are not lined up.

Also, some companies have a policy against this kind of data being sent to gmail, so make sure you are good with regards to data security policy.

If you think this message has been helpful, please assign points. I collect them. Kind of like stamps.

No electrons were harmed in the creation of this post.

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
Kapil Jha
Honored Contributor

Re: how send cron job logs to gmail id?

If your system has connectivity with external world you just mail to type

mail -s subject abc@pqr.com < file name

this would sent content to specified account.
As said above gmail is not a good idea from security, so keep it in mind.

BR,
Kapil+
I am in this small bowl, I wane see the real world......
Logu_2
Advisor

Re: how send cron job logs to gmail id?

Cron has this feature inbuilt. On top of the crontab file assign the MAILTO variable as follows

MAILTO=yourgmail@gmail.com

By default it uses local smtp server, not sure if gmail policies will allow them to accept mail from your IP.