LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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


Closed Thread
  Search this Thread
Old 11-13-2013, 12:54 AM   #1
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Rep: Reputation: Disabled
crontab help


Hi,

I want to configure crontab to run particular command and crontab should forward that email to an ip address because we have configured mail relay.
 
Old 11-13-2013, 02:22 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

do you have a question? Do you need help with something?

Evo2.
 
Old 11-13-2013, 02:27 AM   #3
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
Thnx for replying.

Yes, that was my question. how to forward email to mail relay server using crontab?
 
Old 11-13-2013, 02:32 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

I'm still not sure what you are asking. Are you asking how to write a crontab entry? If so, there is plenty of documentation. For example to send an email every 10 minutes:
Code:
*/10 * * * * /path/to/script/that/sends/an/email
Evo2.
 
Old 11-13-2013, 02:47 AM   #5
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
No dude, i know how to make an entry in crontab. my question is:--
we can send mail to perticular mail id through crontab using MAILTO variable , if jobs are completed. but i wanna forward that mail to mail relay server. i know the ip of mail relay. plz tell me how to configure it? because there is no documentation on this.
 
Old 11-13-2013, 03:19 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Cron/Crontab was created to execute scheduled jobs, when it comes to mailing information, crontab relies on the presence of a mail facility. Mail forwarding is done by a mailing service and not crontab (cron/crontab is dumb in that regard).

Could you describe what your actual problem is? It looks like you've already chosen a certain path to look for a solution (change something in cron/crontab, which seems to be the wrong path).
 
Old 11-13-2013, 03:40 AM   #7
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post
Cron/Crontab was created to execute scheduled jobs, when it comes to mailing information, crontab relies on the presence of a mail facility. Mail forwarding is done by a mailing service and not crontab (cron/crontab is dumb in that regard).

Could you describe what your actual problem is? It looks like you've already chosen a certain path to look for a solution (change something in cron/crontab, which seems to be the wrong path).


Basically i created a centos mirror and i created a BASH script to update those packages on regular basis and scheduled it at 5am. i want to send a mail when it completes the job.
we have configured mail relay on another host. and i want whatever mail is sent when packages are updated that should be forwarded to that mail relay(192.168.0.X). and from there it will automatically be transferred to user mail box.
 
Old 11-13-2013, 03:57 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by sachin.davra View Post
Basically i created a centos mirror and i created a BASH script to update those packages on regular basis and scheduled it at 5am. i want to send a mail when it completes the job.
That's the script part that runs from crontab. No problems there.

Quote:
we have configured mail relay on another host. and i want whatever mail is sent when packages are updated that should be forwarded to that mail relay(192.168.0.X). and from there it will automatically be transferred to user mail box.
The mail service you use on the mirror should be configured to do this and not cron.

Cron just sends mail to (for example) some.user@some.location.com and after it gives this mail to the mailer its job is done. The mail service decides what needs to be done with this specific mail.

Maybe this link will help: 23.3. Mail Transport Agents
 
Old 11-13-2013, 04:05 AM   #9
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post
The mail service you use on the mirror should be configured to do this and not cron.

Cron just sends mail to (for example) some.user@some.location.com and after it gives this mail to the mailer its job is done. The mail service decides what needs to be done with this specific mail.
It's little bit clear to me now. Does it mean that on my localhost, where i have created a mirror for centos, mail service (sendmail) should be configured? if so then plz tell me if i will configure forwarding in sendmail to a mail relay then user should get mail.
If that is the case, in that case what should be the "MAILTO" in crontab?

If i am wrong. plz correct me.
 
Old 11-13-2013, 05:13 AM   #10
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by sachin.davra View Post
Does it mean that on my localhost, where i have created a mirror for centos, mail service (sendmail) should be configured?
If your mail needs to go to another location (not the local machine): Yes, you need to install and configure an MTA (sendmail is one of those, Postfix is another one).

Quote:
if so then plz tell me if i will configure forwarding in sendmail to a mail relay then user should get mail.
I'm not sure what it is your are asking/telling.

Quote:
In that case what should be the "MAILTO" in crontab?
MAILTO should contain the email address that mail should be send to. If the recipient is not on the local machine then a valid e-mail address must be used: user1@some.address.net (and _not_ just user1)
 
Old 11-13-2013, 05:18 AM   #11
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post

MAILTO should contain the email address that mail should be send to. If the recipient is not on the local machine then a valid e-mail address must be used: user1@some.address.net (and _not_ just user1)
does it mean that if i will give valid email id in MAILTO variable then cron will try to send mail to this email id via send mail which is configured in the same system and forwarding is enabled to relay.
 
Old 11-13-2013, 05:36 AM   #12
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Quote:
Originally Posted by sachin.davra View Post
does it mean that if i will give valid email id in MAILTO variable then cron will try to send mail to this email id via send mail which is configured in the same system and forwarding is enabled to relay.
try it, see what happens
 
Old 11-13-2013, 05:53 AM   #13
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Firerat View Post
try it, see what happens
in this situation, how should i configure sendmail?
could anyone tell me the configuration of sendmail?
 
Old 11-13-2013, 06:06 AM   #14
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
man sendmail

you may find it is not 'sendmail' but another mail transfer agent (MTA)

consult the documentation for your Linux Distro


^^ assumes you tried it and it 'failed'
 
Old 11-13-2013, 06:07 AM   #15
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by sachin.davra View Post
in this situation, how should i configure sendmail?
could anyone tell me the configuration of sendmail?
There is no out-of-the-box configuration.

- You need to configure your local MTA to use a Smart relay host,
- You need to configure the MTA on your relay host to accept connections from your local MTA.

How this needs to be done depends on which MTA('s) you are using.

If(!!) your local host uses sendmail then editing the DS entry (under # "Smart" relay host (may be null)) should suffice (you do need to restart the service). Only you know the real FQDN (or IP) needs to be used, this is just a dummy example (mail is send to a host called other.mail.host): DSother.mail.host

Setting up the other side (the MTA on other.mail.host) is more complicated. You first of all need to figure out which MTA is used (sendmail, postfix, exim, .. , ..). After that you can configure it to accept mail from the outside.

Last edited by druuna; 11-13-2013 at 06:11 AM. Reason: portfix -> postfix
 
  


Closed Thread



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
[SOLVED] Problem with crontab:: command not executed properly via crontab Ankush Seth Linux - Newbie 11 11-11-2013 06:25 AM
DIff B/w Crontab -l & crontab -e Tareq9959 Linux - Newbie 2 05-14-2013 08:27 AM
linux crontab vs unix crontab ytd Linux - General 2 08-09-2009 05:07 AM
replaced crontab, now should get crontab back to what it was raminn Linux - Newbie 2 10-20-2008 07:15 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM

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

All times are GMT -5. The time now is 01:43 PM.

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
Open Source Consulting | Domain Registration