Problems in generating the mail from cron -- very urgent help me


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Problems in generating the mail from cron -- very urgent help me
# 1  
Old 08-01-2008
Problems in generating the mail from cron -- very urgent help me

Hi,

I wrote a script which generates a mail automatically under certain condition. When i execute the script manually in unix the script is getting executed and the condition works accordingly and the mail is also generated. But when it is pu into cron the mail is not generated and the condition also seems to be going wrong. The return code of the mail command is '1'. Please help me out.

Below is my sample format of my script,

#!/bin/sh
echo "The Job Successfully scheduled at : `date` "
cd **to some path**
ls **some condition** > filetmp.dat
while read line
do
grep $line file.dat > a1.dat
res=`echo $?`
echo "$res"
if [ $res = "1" ]
then
len=`echo $line | wc -c`
echo $len
if [ $len = "30" ]
then
subfile=`echo $line | cut -c1-18`
echo $subfile
cd **to some path**
grep TFS $subfile > a2.dat
tfs=`echo $?`
if [ $tfs = "0" ]
then
echo "FOUND"
else
echo "NOT FOUND"
while read address
do
echo "
Hi ,
This is an alert " | Mail -s "Test Mail" $address
echo "$? --> Mail Status for $address"
done < "addr.dat"
fi
elif [ $len = "44" ]
then
subfile=`echo $line | cut -c1-18`
echo $subfile
cd **to some path**
grep TFS $subfile > a2.dat
tfs=`echo $?`
if [ $tfs = "0" ]
then
echo "FOUND"
else
echo "NOT FOUND"
while read address
do
echo "
Hi ,
This is an alert " | Mail -s "Test Mail: " $address
echo "$? --> Mail Status for $address"
done < "addr.dat"
fi
else
subfile1=`echo $line | cut -c1-35`
echo $subfile1
cd **to some path**
grep TFS $subfile1 > a2.dat
tfs=`echo $?`
if [ $tfs = "0" ]
then
echo "FOUND"
else
echo "NOT FOUND"
while read address
do
echo "
Hi ,
This is an alert" | Mail -s "Test Mail:" $address
echo "$? --> Mail Status for $address"
done < "addr.dat"
fi
fi
fi
done < "filetemp.dat"
mv filetmp.dat file.dat
echo "The Job Successfully ended at : `date` "



Mail is not generated when scheduled into cron and the grep condition is not working when scheduled into cron. Please help me...
# 2  
Old 08-01-2008
use full path in scripts..
/usr/bin/grep
How did you schedule your cron? output of crontab file pls.
# 3  
Old 08-01-2008
i scheduled in the cron as

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /##some path##/myscript.ksh >> /##some path##/myscript.log

output of the log file is...


The Job Successfully scheduled at : Thu Jul 31 07:45:00 MST 2008
61
File name 1
NOT FOUND
1 --> Mail Status for my@mail.com
1 --> Mail Status for other@mail.com
30
File name 2
NOT FOUND
1 --> Mail Status for my@mail.com
1 --> Mail Status for other@mail.com
30
File name 3
NOT FOUND
1 --> Mail Status for my@mail.com
1 --> Mail Status for other@mail.com
44
File name 4
NOT FOUND
1 --> Mail Status for my@mail.com
1 --> Mail Status for other@mail.com
47
File name 5
NOT FOUND
1 --> Mail Status for my@mail.com
1 --> Mail Status for other@mail.com
The Job Successfully ended at : Thu Jul 31 07:45:01 MST 2008

Here for the FIle name 5 the condition is true. Eventhough its comingin as NOT FOUND instead of FOUND. But works fine when executed manually.
# 4  
Old 08-01-2008
please help me out.. itz very urgent and important at this point. Hope can understand my situation.
# 5  
Old 08-01-2008
Please read and respect the rules (4)!

Thank you!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Cron job scheduled is running once, but reports are generating twice

Team, Hope you all are doing fine I have one admin server which is being used dedicately to run cron jobs on hourly basis, fetching the details from Database which is in a different server.These cronjob are run on every hourly/5 minutes basis depending as per end user requirement.The script... (12 Replies)
Discussion started by: whizkidash
12 Replies

2. Shell Programming and Scripting

cron: Clock generating

Hello. I would like to do this : A_VAR_FLAG = "ABCD" +------------+...................................+---------+ ...............................|.................|...................................|.............|... (7 Replies)
Discussion started by: jcdole
7 Replies

3. Red Hat

Problems sending mail: Difference between Mail and Mailx?

Whats the difference between mail and mailx? I'm trying to troubleshoot a problem where I can send mail from server A with this `echo $MESSAGE | mail -s "$SUBJECT" -r $FROM $RECIPIENTS` command but executing the same command from server B throws me this error (Both servers are RHEL) ... (1 Reply)
Discussion started by: RedSpyder
1 Replies

4. UNIX for Dummies Questions & Answers

cron job problem(urgent)

Hey all. Im totally new with makeing websites ect The thing is, i wanted to make one of those pimp games, so i installed a script called mypimpscript.. it works but the 10mins cron jobs dont... ive tried to set it up in cpanel, but im doing it wrong :S right now it looks like this php... (1 Reply)
Discussion started by: princess
1 Replies

5. UNIX for Dummies Questions & Answers

Very Urgent... Problem in generating the mail from crontab

Hi, I wrote a script which generates a mail automatically under certain condition. When i execute the script manually in unix the script is getting executed and the condition works accordingly and the mail is also generated. But when it is pu into cron the mail is not generated and the condition... (1 Reply)
Discussion started by: thiru_cs
1 Replies

6. Shell Programming and Scripting

Generating a report -Formatted printing -Urgent

Hi, My aim is to generate a report using shell script. There are various formats fields coloumns etc. I want to print in a single line (row) but in different coloumn as given below: field1 field2 field3 field4 ....... ....... ...... ....... The spacing... (1 Reply)
Discussion started by: jisha
1 Replies

7. Solaris

mail problems - how to send mail on solaris

Hello I am new user on solaris... I need to configure my solaris to be able to send mails... I know mailx command mailx -s hello address@address.com but I get an error... you have mail in /var/mail/root # hello... User unknown /dead.letter... Saved message in /dead.letter what... (10 Replies)
Discussion started by: amon
10 Replies

8. Shell Programming and Scripting

How to Schedule job using cron(URGENT)

Hello All, I m newbie to Job scheduling. Suppose i have 2 files s1.sh and s2.sh i want to make a schedule such as run s1.sh at 2AM everyday and run s2.sh 9Pm everyday. Can anyone tell me how to schdule that using CRON and i want to know what is CRON and CRONTAB. Thanks in advance (2 Replies)
Discussion started by: ravi.sadani19
2 Replies

9. UNIX for Dummies Questions & Answers

cron problems

Hi there, this time a have a other problem :) i will start a script over the cron. if i start the script manual (per command) it works without any problems, but over the cron it doesent work. my cron looks like this: 26 15 * * * /path/scriptname.sh 2> /path/error.log there is no... (3 Replies)
Discussion started by: scotty
3 Replies

10. UNIX for Dummies Questions & Answers

Very urgent!! Cron problems

I'm having serious problems running cron. I want to create midnight backups of my files on my unix server and there is something wrong with cron. Here is what I do: First I saw that cron is running (while logged on as root) by typing "ps -aedf|grep cron" and I noticed that there is 1 instance... (4 Replies)
Discussion started by: pappous
4 Replies
Login or Register to Ask a Question