Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Problems in generating the mail from cron -- very urgent help me Post 302220520 by thiru_cs on Friday 1st of August 2008 03:21:40 AM
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...
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
CALENDAR(1)						      General Commands Manual						       CALENDAR(1)

NAME
calendar - reminder service SYNOPSIS
calendar [-] [-r] OPTIONS
- Work for every user and send mail to him -r Restrict multiple execution on the same day EXAMPLES
calendar # Check calendar file in current directory calendar # Normary used under the control of cron(8) calendar -r # Normary used in /etc/rc file DESCRIPTION
Basically calendar program consults the file calendar in the current directory and display lines which contain today's or tomorrow's date. Month-day formats such as '12/25', 'Dec. 25', 'december 25', '*/25', '12/*', '*/*' are recognized. The asterisk means 'all' days or 'all' months. On weekends 'tomorrow' extends through next Monday without any consideration about holidays. To prevent ambiguity, the formats '25 Dec.' and '25/12' are not recognized. When an argument - is present, calendar works for all users with a file calendar in their login directories and sends them mail. Normally this is done daily under the control of cron. The -r option does its the same job as - option, but touches the calendar to prevents further access on the same day. Normally this is done in the /etc/rc file on a machine which may be booted several times in one day. SEE ALSO
cron(8). CALENDAR(1)
All times are GMT -4. The time now is 03:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy