Solved

Sendmail question.

Posted on 2007-11-19
7
298 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Do email signature updates give you a headache?

Do you feel like all of your time is spent managing email signatures? Too busy to visit every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Join & Write a Comment

Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Import PST to Exchange using Power Shell new-mailboximportrequest command, you can simply import the PST file into Exchange mailbox or archived. To know How to import PST into Exchange  2013 read the complete article.
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now