Solved

Sendmail question.

Posted on 2007-11-19
7
303 Views
Last Modified: 2013-12-27
Hello,

The old admin is getting email from completed cron jobs.  

1. where is this configured.
2. How could I update it to my email address.  

Here is the email that is coming in:


-----Original Message-----
From: WWW1 Super-User [mailto:root@****.****.com]
Sent: Monday, November 19, 2007 12:12 PM
To: root@***.***.com
Subject: Output from "cron" command

Your "cron" job on HOST
/usr/local/etc/rsync_web >/var/adm/rsync_web.log

produced the following output:

send_files failed to open downloads/fsp_acct.pdf: Permission denied
0
Comment
Question by:simpsonjr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 20314046
Hi,

If the crontab job itself is not sending emails, then the default behavior of crontab is  to capture job output and mail it to the user running the job.

So, if root is the user that run the job, (s)he will continue to receive the emails. You may modify the jobs to send output to your email by piping the output to your mail command that send it to you.

e.g.

If your crontab job run something similar to

* * * * * /usr/bin/ls

then you may change it to

* * * * * /usr/bin/ls | /usr/bin/mail -s "ls output" youremailaddress

a more proper way is to redirect stdout & stderr to a file then mail the file

e.g.

* * * * * /path/to/myscript

where myscript has

/usr/bin/ls > /path/to/output.log 2>&1
/usr/bin/mail -s "ls output" youremailaddress < /path/to/output.log
0
 

Author Comment

by:simpsonjr
ID: 20314119
omarfarid  

Here are the entries in the crontab. I think she is using the second approach, how do I check?

10 3 * * * /usr/sbin/logadm
15 3 * * 0 /usr/lib/fs/nfs/nfsfind
1 2 * * * [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1
30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean
2,7,12,17,22,27,32,37,42,47,52,57 * * * * /usr/local/etc/rsync_web >/var/adm/rsync_web.log
# Start Apache in case it stops
0,10,20,30,40,50 * * * * /usr/local/etc/start_apache.sh
# Switch over the Apache logs
0 0 1,8,15,22 * * /usr/local/etc/newapachelog

 

0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20314127
Hi,

if you want to list root crontab jobs:

As root run

crontab -l > mycrontab

you may edit (e.g. using vi) the file mycrontab to change the way crontab jobs are run

e.g. to change

* * * * * /usr/bin/ls

to

* * * * * /usr/bin/ls | /usr/bin/mail -s "ls output" youremailaddress

Then you may resubmit the crontab jobs

crontab mycrontab

0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
LVL 40

Accepted Solution

by:
omarfarid earned 250 total points
ID: 20314195
Hi,

The initial posting you made seams to be coming from

2,7,12,17,22,27,32,37,42,47,52,57 * * * * /usr/local/etc/rsync_web >/var/adm/rsync_web.log

As you can see, the rsync_web sends output to /var/adm/rsync_web.log , but the sdterr (standard error) is not redirected and hence errors (as I think is the case) are captured and emailed to root.

Now, you can change the line to

2,7,12,17,22,27,32,37,42,47,52,57 * * * * /usr/local/etc/rsync_web >/var/adm/rsync_web.log 2>&1

This will send errors as well to the log file, which you can check from time to time. If you do not want errors to go to the same file, then change to something like

2,7,12,17,22,27,32,37,42,47,52,57 * * * * /usr/local/etc/rsync_web >/var/adm/rsync_web.log 2> /var/adm/rsync_web_errors.log

do not foreget to resubmit your crontab jobs as described earlier
0
 

Author Comment

by:simpsonjr
ID: 20314211
If I am root, can I just use crontab -e and modify the cronjob?

This admin is gone so, I want to have the root email changed to my email, how do I do that?  

Thanks  
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20314366
Hi,

Although you can use the -e option to edit crontab jobs directly, but it is better to keep a copy of the current jobs schedules in a file and  edit the file then resubmit. Many administrators do mistakes while editing directly (and hence loose what what scheduled).

Now, coming to your question on how to send emails to you (not root).

There are many ways:

1- for each scheduled job just follow the example where you pipe output and errors to mail. I will take simple example and you can do similar

* * * * * /usr/bin/ls 2>&1 | mail -s "ls output" youremailaddress

2- Or you may edit each script scheduled and redirect output and error (of commands run in the script) to a file then email the file to your self. I will repeat the example here:

* * * * * /path/to/myscript

where myscript has

/usr/bin/ls > /path/to/output.log 2>&1
/usr/bin/mail -s "ls output" youremailaddress < /path/to/output.log

3- You may forward all emails coming to root to your self (All, which could be troublesome!) by creating /.forward file and add your email address to it. Please see

man forward

for more details
0
 

Author Comment

by:simpsonjr
ID: 20314467
Thanks for all the help!!!!

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
spectrum scale snapshot  resotre/mount 1 57
lunix and unix command 21 150
Email Archiving -- Office365 accounts ? 5 68
Exchange 2010 Plans with Exchange Online 2 55
Utilizing an array to gracefully append to a list of EmailAddresses
As cyber crime continues to grow in both numbers and sophistication, a troubling trend of optimization has emerged over the last year.
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question