Solved

Sendmail question.

Posted on 2007-11-19
7
302 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
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Microsoft has released various new features which are capable of handling various tasks. One of these tasks is ‘Migration from pop3 to Exchange Server’. Pop3 data stores various data along mailboxes like contacts, tasks, etc. So, it becomes the need…
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
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…

685 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