The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Telnet Script Issues Darknight Shell Programming and Scripting 10 02-09-2009 03:09 PM
UNIX Guru's help on diff ajaybalki Shell Programming and Scripting 2 06-22-2006 06:51 PM
Reboot problem !!! urgent plse !!!!!!!!!!! tt155 SUN Solaris 8 01-15-2006 01:33 AM
define nvalias's cdrom URGENTLY plse!!! tt155 SUN Solaris 1 11-21-2005 07:38 AM
what do most Unix guru's use ? :D simon2000 UNIX for Advanced & Expert Users 6 09-01-2003 10:00 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-09-2006
budrito budrito is offline
Registered User
  
 

Join Date: Jul 2002
Posts: 22
UNIX script issues - Plse help guru's

Hi,

I have written the following UNIX for HP-UX 11i. The script basically checks for files older then 45mins in 2 repective directories and then sends and email to the administrator about them.

Problem with the script is that I can run it from the command line and crontabtab but 80% of the time it errors out with the following error message "date: bad conversion".

I'm puzzled as to why it works brilliantly sometimes and why majority of the times it errors out with the above error message. Can a UNIX scripting guru please advise. Script displayed below:

#!/usr/bin/ksh
mailgroup='testuser@xxx.com'

LOGFILEIN=/tmp/sipstimein.log
LOGFILEPROC='/tmp/sipstimeproc.log'

#GET AND PARSE THE CURRENT DATE
date "+%m %d %H %M" | while read MONTH DAY HOURS MINS
do

#SUBTRACT 45 MIN
MINS=$(($MINS-45))

if [ $MINS -lt 0 ]
then
HOURS=$(($HOURS-1))
MINS=$(($MINS+60))
fi

#TOUCH A FILE SO THAT IT IS 45 MINUTES OLD
touch -t ${MONTH}${DAY}${HOURS}${MINS} /tmp/oldtime
done

#Find files older then 45mins condition
find /interface/data8/sips/proc ! -newer /tmp/oldtime | while read FILENAME
do
#CHECK THAT IT IS A REGULAR FILE, AND NOT A DIR OR
# CHARACTER FILE, BEFORE RUNNING THE COMMAND AGAINST IT
if [ -f $FILENAME ]
then
echo "$FILENAME" >$LOGFILEIN
sleep 4
mailx -s "Files have been detected older then 45mins in PROD system for SIPS in the PROC directory" <$LOGFILEIN $mailgroup
2>&1
fi
done

find /interface/data8/sips/in ! -newer /tmp/oldtime | while read FILENAME
do
#CHECK THAT IT IS A REGULAR FILE, AND NOT A DIR OR
# CHARACTER FILE, BEFORE RUNNING THE COMMAND AGAINST IT
if [ -f $FILENAME ]
then
echo "$FILENAME" >$LOGFILEPROC
sleep 4
mailx -s "Files have been detected older then 45mins in PROD system for SIPS in the IN directory" <$LOGFILEPROC $mailgroup
2>&1
fi
done

#rm /tmp/oldtime

THANKS and help appreciated.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0