Crontab email issue


 
Thread Tools Search this Thread
Operating Systems Solaris Crontab email issue
# 1  
Old 06-18-2008
Crontab email issue

Hi,

I have a script that sends a db extract file as an email attachment.

I have a crontab created to run it everyday at 8 am..

00 08 * * * ksh /home/rtaaa/tbasd/report.sh > /home/rtaaa/tbasd/logs/report.log

When i just run the "ksh /home/rtaaa/tbasd/report.sh > /home/rtaaa/tbasd/logs/report.log" from the command prompt, the email will be sent out without any issues.. but when its triggered by the crontab, the email is not getting sent.. the whole script is running well except the email part.

This is what i am doing to send the file: "sendmail $ADDR < $MAILFILE"

I have been trying to debug this without success for a while, any help is appreciated.

Thanks.
# 2  
Old 06-18-2008
first

take out the ksh in the crontab and include
#!/bin/ksh
at the top of the script.

second

you can record the errors in your log with 2>&1

so give this a shot:
Code:
00 08 * * * /home/rtaaa/tbasd/report.sh >> /home/rtaaa/tbasd/logs/report.log 2>&1

# 3  
Old 06-19-2008
found the culprit

Thanks for helping me find the error..

Now i could trace the error:

but i am getting this error: "sendmail: not found"

Again, I am getting this error only when Its run by the cron. I won't get this when i run it from the command prompt.

thanks,
Rama
# 4  
Old 06-19-2008
Quote:
Originally Posted by ryannam
Thanks for helping me find the error..

Now i could trace the error:

but i am getting this error: "sendmail: not found"

Again, I am getting this error only when Its run by the cron. I won't get this when i run it from the command prompt.

thanks,
Rama

Best way to solve this (considering best practices) is specify full path name to sendmail in the script. You can find out where sendmail lives by typing:

which sendmail

(hint: it's probably /usr/lib/sendmail)
# 5  
Old 06-20-2008
How to disable crontab from sending email to user from configuration.?

I mean instead of redirecting > /dev/null 2>&1 at the crontab entry.
# 6  
Old 06-20-2008
Crontab email issue

Instead of specifying the complete pathname for each program,
you might want to make the script self-sufficient by including PATH and umask settings:

PATH=/bin:/usr/bin:/usr/lib:/usr/local/bin
export PATH
umask 022

Handle all redirection within the script as well. It also helps to create a directory just for cron jobs, so your final script would be something like /usr/local/cron/run-report.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Another issue with crontab

My shell script it.sh #!/bin/sh ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH today=`date "+%m-%d-%Y %H:%M:%S"`; export today CUR_DIR=$1; export CUR_DIR LOG_FILE=$CUR_DIR/error.log; export LOG_FILE # Direct... (30 Replies)
Discussion started by: rafa_fed2
30 Replies

2. Shell Programming and Scripting

Crontab issue

hi, i have schduled a job through crontab, but it is not getting executed. bash-3.2$ crontab -l # Monthly Download (mm hh DD MM format) 35 05 01 04 * /home/ftpsrp/srpftp1/download/ofrdb/scripts/load_ofrdb.sh crr.sh here is the permission of the .sh files -rwxr--r-- 1 ftpsrp srp ... (7 Replies)
Discussion started by: lovelysethii
7 Replies

3. UNIX for Dummies Questions & Answers

How to change crontab output from console to email?

Hi, We are currently running AIX 6.1 TL4. There are around 30 ksh scripts that are ran from crontab which if an error occurs or a problem with an ftp unix sends the out of the ksh script which goest to our console via the local user hci which is viewed by the mail command. I've tired adding... (2 Replies)
Discussion started by: hgjdv
2 Replies

4. UNIX for Advanced & Expert Users

Crontab issue

We have configured a script to be run at specific time using crontab. # crontab -l 15 11 * * * VM_Count_V4.shas per the crontab entry script should run every day 11.15 a.m Every time when the script is executed i get a mail but when i run it using crontab it doesn't send any mail. However... (1 Reply)
Discussion started by: pinga123
1 Replies

5. Shell Programming and Scripting

Crontab issue: getting email but with out body

I have a oracle sh script test.sh #!/bin/bash R=`sqlplus -S *****/*********@dfsdf <<ENDOFSQL set serveroutput on size unlimited; execute DBMS_SNAPSHOT.REFRESH( '"MIS_ADMIN"."MV_SURVEY_UNITS_CENSUS"','F'); execute DBMS_SNAPSHOT.REFRESH( '"MIS_ADMIN"."MV_SURVEY_UNITS_CENSUS_PART"','F');... (1 Reply)
Discussion started by: ramkia6
1 Replies

6. AIX

Crontab - Email notifications by alternate user

Hi, I have a crontab which sents email to a group in a certain interval. The email contains my user id in 'from' field of email - because my user crontab. I don't have root access for that AIX 5.3 host - and should have to change 'from' field to either 'root' or any other common names. ... (4 Replies)
Discussion started by: vasukv
4 Replies

7. Shell Programming and Scripting

Issue with crontab

I have a ksh script which will connect to a database and executes some sql scripts. If i run the ksh script it is working fine. But if i schedule it to run at a perticular time using cron the sql script is not running. The scriptl initially creates a spool file for sql script and then connects and... (12 Replies)
Discussion started by: Sriranga
12 Replies

8. Shell Programming and Scripting

Crontab change and email notification

Hey guys Just need some help with crontab.Iam looking for a script that will alert particular user about its change through sendmail.We are using bash here. --CoolKid (3 Replies)
Discussion started by: coolkid
3 Replies

9. UNIX for Dummies Questions & Answers

Crontab Issue

I have a backup script that is suppose to run every night of the week, but it never does, it starts to run. The way I can tell is that the dates on dump_log are changing to when the script runs. If I look in the cron log file is shows ! > root 506342 cr /etc/back_up Fri Aug 5 10:30:00... (2 Replies)
Discussion started by: rickyt00
2 Replies

10. Solaris

crontab issue

Can someone help with a cron issue on a Sun Solaris 9 machine? The problem I am having is that one of my cron jobs is sending output to the /var/mail/root and I am trying to get it to stop. I have other cron jobs that are running that do not place any output to that location. They do however send... (6 Replies)
Discussion started by: Semper_Tempus
6 Replies
Login or Register to Ask a Question