Sleep - Send Email


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Sleep - Send Email
# 1  
Old 02-03-2006
Sleep - Send Email

Working on a script to look in a directory for a certain file. If the file is not there, check the time. If the time is greater than 10:00, send me an email. If it's not, sleep for 15 minutes and then do this all over again.

I can get it to email me if the file's not there without the sleep portion. Once I add the sleep, it appears to be working (I run the script and it waits until 10:00 to bring the command prompt back), but it doesn't send an email.

What am I doing wrong?

Here's the snippet of code:

if [ ! -s $DATA_DIR/test2.das ]
then

now=`date +'%H%M'`
if test $now -gt 1000
then
/usr/bin/echo $MESG_DELAY | /usr/bin/mailx -s $MESG_DELAY here@there.com

else
sleep 900

fi
# 2  
Old 02-06-2006
Script to send mail

Your problem lies here
/usr/bin/mailx -s $MESG_DELAY here@there.com

You could check the link.
# 3  
Old 02-06-2006
Hmmm...there are other scripts running in cron jobs (which is where I want to put this, when it's working) that have that mailx line and are working as designed. In fact, this script works as designed until I put in the sleep.

I think the problem is, with my current code, I'm telling it to sleep, but then never do anything after the sleep. So it's coming back after x minutes and completing, but not really doing anything. I need something after the sleep to tell it to try again.

How can I "name" the nested test so that I can easily refer back to it again after the sleep? Rather than duplicating the code?
# 4  
Old 02-06-2006
Code:
while true
do
    if [ ! -s ./test2.das ]
    then
        now=`date +'%H%M'`
        echo $now
        if test $now -gt 1000
        then
           /usr/bin/echo $MESG_DELAY | /usr/bin/mailx -s $MESG_DELAY               here@there.com
           exit
        else
           sleep 20
        fi
    else
# Put what you need to do if it DOES find the file here and add another exit or this will keep repeating!
fi
done

Next time add more detail (such as what you shell you are writting in).
# 5  
Old 02-07-2006
KSH...thanks for this, I will play around with it a bit, after I put out some fires.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send sleep to background

Hello all, I've a small script where it checks for the existence of a particular file and sleeps for 5 seconds if it doesn't exist. I would like to send the sleep output to background so that I don't see so many sleep messages in the build output. #!/bin/sh -x until do sleep 3 done echo... (17 Replies)
Discussion started by: builderj
17 Replies

2. SuSE

Send outgoing email to my GroupWise email

Dear users, I have Linux server whose versions are Suse 10 SP 3 and Suse 11. I am trying to send email from these servers to my GroupWise email account. In /etc/postfix/main.cf file, The current value of MYHOSTNAME is LINUX.LOCAL. What should be the right value of MYHOSTNAME? Is... (0 Replies)
Discussion started by: JDBA
0 Replies

3. Shell Programming and Scripting

send email to email id which is having # symbol

Hi, I have one requirement to send email to email id which is having # ( in the begining of the email id). I'm using mailx command to send an email. But not receiving those emails, but email status is showing email sent successful. Code which i'm using is : cat file1.txt | mailx -s... (3 Replies)
Discussion started by: latika
3 Replies

4. UNIX for Dummies Questions & Answers

new to ldap, send email to a ou or group, and see a list from email client

hi, i'm running openldap on ubuntu 10.04, creating new items with apache directory studio (windows version). i use the ldap just as an address book to our small office (email clients are windows live mail 2009, 2011, microsoft outlook 2007 and 2010). a. i cant see a list of the contacts,... (0 Replies)
Discussion started by: V4705
0 Replies

5. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

6. Solaris

Send an email from Solaris using Linux email server

Hello everyone I have a problem and I need your help: I have a Solaris 10 and Solaris 8 UNIX Servers, and Linux Centos4 as email server. I need send an email from Solaris servers preferably using Centos4 email server. I have no mail service configured in my Solaris computers (1 Reply)
Discussion started by: aflores
1 Replies

7. UNIX for Dummies Questions & Answers

Send email where # is in the email address - Using Unix

Hi All, How do I send an email using malix where email address contains a #. I have a email address like this : #test@test.com I want to send email like malix -s "TEST" #test@test.com < SOMEFILE I tried \# but doesn't work. Please let me know how we can achieve this? I am in... (1 Reply)
Discussion started by: jingi1234
1 Replies

8. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies
Login or Register to Ask a Question