Cron Sends mail to root on completion of job.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Cron Sends mail to root on completion of job.
# 1  
Old 04-25-2003
Question Cron Sends mail to root on completion of job.

All
I am running a few scripts through a cron job. This is for checking some key services that are running on by box. The problem is, everytime the cron runs, it sends a mail to the root account. The root account mails need to cleared every now and then. Is there some way I can stop these mails from being sent or to send the mail only on failure of execution?

I am running Redhat Linux 7.3.

Thanks all in advance!!

KS
# 2  
Old 04-25-2003
Here's a blurb from unixgeeks.org (note the bold):
Quote:
Output from cron

As I've said before, the output from cron gets mailed to the owner of the process, or the person specified in the MAILTO variable, but what if you don't want that? If you want to mail the output to someone else, you can just pipe the output to the command mail.

e.g.

cmd | mail -s "Subject of mail" user

If you wish to mail the output to someone not located on the machine, in the above example, substitute user for the email address of the person who wishes to receive the output.

If you have a command that is run often, and you don't want to be emailed the output every time, you can redirect the output to a log file (or /dev/null, if you really don't want the output).

e.g.

cmd >> log.file


Notice we're using two > signs so that the output appends the log file and doesn't clobber previous output. The above example only redirects the standard output, not the standard error, if you want all output stored in the log file, this should do the trick:

cmd >> logfile 2>&1
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

CRON JOB not running - for tape backup from root user

I am trying a cron on root user to backup to tape using TAR command here is the cron entry 11 08 * * 6 /erdhot1cron 2>&1 >> /test3/scripts/dba/erdhot1cron.log here is script inside - edhot1cron #!/bin/bash vsysdt=`date +%d%m%y` date tar -cvf /dev/st0... (4 Replies)
Discussion started by: vijaymec50
4 Replies

2. UNIX for Dummies Questions & Answers

Create cron job without root

Hi there, I need to create a crone job to backup certain files on my disk without root permissions. Also if I will be able to edit cronetab then I need to know how to edit it with any editor other than vim :mad: (5 Replies)
Discussion started by: aelhosiny
5 Replies

3. Homework & Coursework Questions

Creating a function that sends a mail using mail command

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: The function will be called m and it will allow you to send an email to someone using the mail command. The... (1 Reply)
Discussion started by: Drucian
1 Replies

4. Shell Programming and Scripting

how to run a script using cron job and send the output as attachment via e-mail using unix

how to run a script using cron job and send the output as attachment via e-mail using unix. please help me. how my cron job entry should be? As of now my cron job entry is to run the script at specific time, 15 03 * * * /path/sample.sh | mail -s "Logs" email_id In the above entry, what... (8 Replies)
Discussion started by: vidhyaS
8 Replies

5. Shell Programming and Scripting

Cron job initiating ssh AND sudo (from user, not root)

I've been bashing my head on the desk for 2 days trying to get this to work, but I've had no luck. I'll try to be as clear as possible in my explanation without dragging out the details. I'm trying to set up a cron job for user "john" which runs a script. This script initiates an ssh connection to... (5 Replies)
Discussion started by: eh3civic
5 Replies

6. Shell Programming and Scripting

check mail backup cron job

i have just installed a cron job to run at 3 in the morning once a week. It's difficult for me to test if it works because the email backup program takes the email service down before running the backup. I wondered if i could ask you gurus if this would work? 0 3 * * 0 ... (1 Reply)
Discussion started by: timgolding
1 Replies

7. Shell Programming and Scripting

Adding a new root cron job

Hi there, I have over 2000 systems (mainly Solaris) and I want to write a script that inserts a new root cronjob on each of those servers. obviously just adding a line to /var/spool/cron/crontabs/root looks like the easiest way, but i really dont want to have to send a HUP to crond on all boxes ... (3 Replies)
Discussion started by: rethink
3 Replies

8. UNIX for Advanced & Expert Users

Completion time of a cron job ?

how can we identify the task completion time which was initiated by CRON. we have 1000 of jobs whihc are runing from cron so it is not feasable to edit every cron entry or every script to add the respective code to find teh completion time. Can some one please provide a inut to find the task... (3 Replies)
Discussion started by: NIMISH AGARWAL
3 Replies

9. Red Hat

Sendmail sends messages like root

Hi, we are setup sendmail like a relaying. We are using user authetecing in the smart mail host. But when we use sendmail to send a message, the message is rejected, because user root, not is a user known in the domain. Where or what must i do, to can be able to send messages from the sendmail... (0 Replies)
Discussion started by: iroshit
0 Replies

10. UNIX for Dummies Questions & Answers

cron job not running to completion

am running a cron job to do a backup of all user files. the script runs properly in the terminal but only backups about 20% of the files when run by cron. the Linux system is running BASH as far as I can tell. the symbols $FILE and $DIRECTORY are defined properly and the following is the... (1 Reply)
Discussion started by: novice633
1 Replies
Login or Register to Ask a Question