LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   crontab help (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-help-4175484402/)

sachin.davra 11-13-2013 12:54 AM

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.

evo2 11-13-2013 02:22 AM

Hi,

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

Evo2.

sachin.davra 11-13-2013 02:27 AM

Thnx for replying.

Yes, that was my question. how to forward email to mail relay server using crontab?

evo2 11-13-2013 02:32 AM

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.

sachin.davra 11-13-2013 02:47 AM

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.

druuna 11-13-2013 03:19 AM

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).

sachin.davra 11-13-2013 03:40 AM

Quote:

Originally Posted by druuna (Post 5063575)
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.

druuna 11-13-2013 03:57 AM

Quote:

Originally Posted by sachin.davra (Post 5063588)
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

sachin.davra 11-13-2013 04:05 AM

Quote:

Originally Posted by druuna (Post 5063596)
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.

druuna 11-13-2013 05:13 AM

Quote:

Originally Posted by sachin.davra (Post 5063600)
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)

sachin.davra 11-13-2013 05:18 AM

Quote:

Originally Posted by druuna (Post 5063622)

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.

Firerat 11-13-2013 05:36 AM

Quote:

Originally Posted by sachin.davra (Post 5063623)
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

sachin.davra 11-13-2013 05:53 AM

Quote:

Originally Posted by Firerat (Post 5063627)
try it, see what happens

in this situation, how should i configure sendmail?
could anyone tell me the configuration of sendmail?

Firerat 11-13-2013 06:06 AM

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'

druuna 11-13-2013 06:07 AM

Quote:

Originally Posted by sachin.davra (Post 5063633)
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.


All times are GMT -5. The time now is 12:50 AM.