LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-29-2007, 07:26 AM   #1
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Rep: Reputation: 30
cron output


Hai all,

am runnin some cronjobs daily.

Is thereanyway, the output of this cronjob can be sent to any other mail id's other than OS users.

now it is sending to root user.

I need to send it to any external account.. is this possible ?.. if so , how ?

Please guide


Yusuf
 
Old 11-29-2007, 07:46 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
You can assign the variable MAILTO at the beginning of the crontab, with a complete e-mail address, e.g.
Code:
MAILTO="colucix@some.domain.it"
20 * * * * echo $HOME
35 * * * * date
 
Old 11-29-2007, 04:18 PM   #3
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by colucix View Post
You can assign the variable MAILTO at the beginning of the crontab, with a complete e-mail address, e.g.
Code:
MAILTO="colucix@some.domain.it"
20 * * * * echo $HOME
35 * * * * date

Thanks colucix, but for the same .. is it necessary to have sendmail configured in that machine..

If so , is there anyway we can change the subject of the mail as per user requirements or wish .

Please comment and guide

Yusuf
 
Old 11-30-2007, 06:28 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by yusufs View Post
Thanks colucix, but for the same .. is it necessary to have sendmail configured in that machine..
If I'm not wrong, cron uses sendmail by default. Maybe someone can help to clarify this point.

Quote:
If so , is there anyway we can change the subject of the mail as per user requirements or wish
No. The crontab does not permit such a refinement. However if the user needs some output to be e-mailed, he/she can always use sendmail (or any other mailer) inside the script. E.g. something like
Code:
/usr/sbin/sendmail "m.rossi@domain.it" << EOF
From: colucix <colucix@null.domain>
To: Mario Rossi <m.rossi@domain.it>
Subject: my personalized subject $VARIABLE

`date "+%A %e %b %Y %T"` - my message here

`cat log_to_display_in_mail_body.log`

EOF
in this way you can send (in the subject or in the body of the e-mail) the content of any variable or any log generated by the script itself or the output of any command. Just an idea.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron e-mail output fyr3 Slackware 1 07-16-2007 03:51 PM
cron output nelamvr6 Linux - Newbie 3 10-18-2005 08:11 PM
Cron output to a file Temujin_12 Linux - General 5 02-23-2005 02:52 PM
cron output? sk8guitar Linux - General 4 08-15-2003 02:55 PM
Understanding CRON output lhoff Linux - General 1 05-19-2003 02:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration