Sponsored Content
Top Forums Shell Programming and Scripting UNIX script issues - Plse help guru's Post 98656 by budrito on Thursday 9th of February 2006 07:01:05 PM
Old 02-09-2006
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.
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

what do most Unix guru's use ? :D

I wanted to know what email app most Sun solaris / unix gurus use ? I have become quite NON microsoft in the last few months in my studying solaris.. thanks simon2000 (6 Replies)
Discussion started by: simon2000
6 Replies

2. Solaris

define nvalias's cdrom URGENTLY plse!!!

I need help please ....... I have to urgently setup nvalias 's cdrom ....... following are the output command ...................... {7} ok banner Sun Fire 3800 OpenFirmware version 5.15.2 (08/04/03 10:27) Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved. Use is... (1 Reply)
Discussion started by: tt155
1 Replies

3. Solaris

Reboot problem !!! urgent plse !!!!!!!!!!!

Operatin System : Solaris 5.9 Server : Sun Fire 3800 Shutdown and reboot i receive the following messages ..... un Fire 3800 OpenFirmware version 5.15.2 (08/04/03 10:27) Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. SmartFirmware,... (8 Replies)
Discussion started by: tt155
8 Replies

4. Shell Programming and Scripting

UNIX Guru's help on diff

Hi , I wanted to find delata between two huge ( 8 GB ) files . Say file_TDY and file_YDY : These files are sorted based on a key . I am using a command : 1)bdiff file_TDY file_YDY > diff_file 2) grep ' ^< ' diff_file > TDY_delta I wanted only the changed records and newly added... (2 Replies)
Discussion started by: ajaybalki
2 Replies

5. HP-UX

Make_Recovery Question Urgent Plse Respond

I have a make_recovery tape, if I restore the VG00 volume group using this, will my other volume groups still be ok after the restore(I have 7 data volume groups) I used make_recovery -A to create the tape I have a HP9000 HP-UX 11 An internal disk is failing, the other volume groups are on... (3 Replies)
Discussion started by: rees_a
3 Replies

6. Solaris

Advice to become a unix guru?

Hello, I have recently completed my training for Solaris 10 and have a good understanding of the bases now. I am playing around with my system but can't do much since my knowledge is limited. I am looking for some projects or some threads where I can learn more and expand my knowledge step by... (16 Replies)
Discussion started by: saudsos
16 Replies

7. Shell Programming and Scripting

Unix bash script (mv issues);

Hey guys, I've registered here as I need urgent help. This is assignment for school and as you can see below I've completed the work. I'm simply stuck on one area. :wall: This script takes the first parameter (which is to be the new extension) and each parameter after that is a file... (1 Reply)
Discussion started by: Cynosure
1 Replies

8. Shell Programming and Scripting

Issues for script that login to a unix box

Hi, I have a script that should login to a different box then the box that i am in and run the commands. I have the script sample below that logins to a unix box and get the files .Looks like ls-lrt command is not running or its wrongly used. #!/bin/bash # Ask the user for build month... (5 Replies)
Discussion started by: learninguser235
5 Replies

9. Shell Programming and Scripting

Shell script guru

Hey Gurus, Need help to modify the shell script. I am really new in the Linux/Unix world and dont familiar with shell scripting. SO bascially my script is running a ( curl ) with some endpoints and returning HTTP status code. Now i have a 50 different endpoints and cant make each and individual... (3 Replies)
Discussion started by: Zach Kadiwal
3 Replies
LEARN(1)						      General Commands Manual							  LEARN(1)

NAME
learn - computer aided instruction about UNIX SYNOPSIS
learn [ -directory ] [ subject [ lesson ] ] DESCRIPTION
Learn gives Computer Aided Instruction courses and practice in the use of UNIX, the C Shell, and the Berkeley text editors. To get started simply type learn. If you had used learn before and left your last session without completing a subject, the program will use information in $HOME/.learnrc to start you up in the same place you left off. Your first time through, learn will ask questions to find out what you want to do. Some questions may be bypassed by naming a subject, and more yet by naming a lesson. You may enter the lesson as a number that learn gave you in a previous session. If you do not know the lesson number, you may enter the lesson as a word, and learn will look for the first lesson containing it. If the lesson is `-', learn prompts for each lesson; this is useful for debugging. The subject's presently handled are files editor vi morefiles macros eqn C There are a few special commands. The command `bye' terminates a learn session and `where' tells you of your progress, with `where m' telling you more. The command `again' re-displays the text of the lesson and `again lesson' lets you review lesson. There is no way for learn to tell you the answers it expects in English, however, the command `hint' prints the last part of the lesson script used to evaluate a response, while `hint m' prints the whole lesson script. This is useful for debugging lessons and might possibly give you an idea about what it expects. The -directory option allows one to exercise a script in a nonstandard place. FILES
/usr/share/learn subtree for all dependent directories and files /usr/tmp/pl* playpen directories $HOME/.learnrc startup information SEE ALSO
csh(1), ex(1) B. W. Kernighan and M. E. Lesk, LEARN - Computer-Aided Instruction on UNIX BUGS
The main strength of learn, that it asks the student to use the real UNIX, also makes possible baffling mistakes. It is helpful, espe- cially for nonprogrammers, to have a UNIX initiate near at hand during the first sessions. Occasionally lessons are incorrect, sometimes because the local version of a command operates in a non-standard way. Occasionally a lesson script does not recognize all the different correct responses, in which case the `hint' command may be useful. Such lessons may be skipped with the `skip' command, but it takes some sophistication to recognize the situation. To find a lesson given as a word, learn does a simple fgrep(1) through the lessons. It is unclear whether this sort of subject indexing is better than none. Spawning a new shell is required for each of many user and internal functions. The `vi' lessons are provided separately from the others. To use them see your system administrator. 7th Edition October 22, 1996 LEARN(1)
All times are GMT -4. The time now is 03:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy