I am working one below script. I am stuck at the else condition.
Code:
#!/bin/ksh
while :
do
cur_date=`date |cut -d"," -f 1`
cur_time=`date +"%H%M"
if [ "$cur_date" != "Saturday" ]||[ "$cur_date" != "Sunday" ]; then
if [ ! -f $FIRST_FILE ] && [ $cur_time -ge 2200 ]; then
echo "File " $FIRST_FILE " doesn't exist!"
exit 30
elif
[ ! -f $FIRST_FILE ] && [ $cur_time -le 2200 ]; then
"here I want to the script jump to sleep directly without execute the below loop."
else
fyr=`ls -e $FIRST_FILE |awk '{print $9}'`
echo $fyr
mth=`ls -e $FIRST_FILE |awk '{print $6}'`
dy=`ls -e $FIRST_FILE |awk '{printf "%0.2d\n", $7}'`
time=`ls -e $FIRST_FILE |awk '{print $8}'`
echo "arr, start_file, $file, $fyr, $mth, $dy, $time" >> "$SRCDIR"/arr_code_list
fi
fi
while IFS="," read code folder file suffix
do
filedir="$SRCDIR"/"$folder"
inputfile="$filedir"/"$file"
suffix=$suffix
if [ -f ${inputfile}[0-9]*${suffix} ] ; then
ofile=`ls -1tr $inputfile*|head -1`
mth=`ls -e $ofile |awk '{print $6}'`
dy=`ls -e $ofile |awk '{printf "%0.2d\n", $7}'`
time=`ls -e $ofile |awk '{print $8}'`
yr=`ls -e $ofile|awk '{print $9}'`
echo "$code, $file, $yr, $mth, $dy, $time" >> "$SRCDIR"/arr_code_list
else
echo "$code, $folder, $file, NOT FOUND" >>"$TGTDIR"/not_arrival_list
fi
done < $FEED_LIST
sleep 900
done
the script checks file every 15 minutes
the requirement as like below
for weekday, then check $FIRST_FILE first,
if $FIRST_FILE arrived before 10:00Pm, then checking rest file,
if $FIRST_FILE not arrive before 10:00pm then sleep 15 minutes then start loopping again.
if $FIRST_FILE not found after 10:00pm, script exit with error code.
for weekend only checking other files without checking $FIRST_FILE;
in above script, I don't know how to jump to sleep if the $FIRST_FILE not arrival but time is early then 10:00 PM. (highlited in red)
Difficult for me to visualise, wondering if a break would do the the trick, with the elsif rather than a else if I am a bit lost with your indentation... ( and I have a poor eyesight...)
(changed glasses...)
seems not... You would have to add a flag in that if, then add an extra if condition for the second part using the flag (just before while IFS=...
Difficult for me to visualise, wondering if a break would do the the trick, with the elsif rather than a else if I am a bit lost with your indentation... ( and I have a poor eyesight...)
(changed glasses...)
seems not... You would have to add a flag in that if, then add an extra if condition for the second part using the flag (just before while IFS=...
Thanks for your reply. you mean as below, right?
Code:
# in my elif
[ ! -f $FIRST_FILE ] && [ $cur_time -le 2200 ]; then
flag==0
...
# in my second while add
if [ flag -eq 1]; then
while IFS=",", read ...
.
.
done < $FEED_LIST
fi
sleep 900
I use this as a startup program.
Is there a way that it could run when my computer returns from a sleep state?
Cpu_LogFile="/home/andy/bin/CPU_Fan_Info.txt" date +"%Y-%m-%d-%H:%M:%S" >> $Cpu_LogFile sensors -f | grep "temp4" >> $Cpu_LogFile sensors -f | grep "fan1" >> $Cpu_LogFile (5 Replies)
Hi all,
I have a bash script in which it runs multiple if conditions if a word count from a grep is equal to a number. When this number is not reached I want to sleep for very few seconds (let's say 3) and start over again, till it matches the word count of 8.
Here's a sample of the code so... (6 Replies)
Team,
Presently I have a script, which i have set up cron on one of my Jump-boxes,and gives me the output on every hourly basis,fetching the data from the remote machine.Basically it gives me the list of all active users logged and its count once we execute the script.Here the count is... (6 Replies)
Fairly new to the System Admin world, and this is my first post here, hoping to get some clarification.
I am using a BASH script to automate some Logfile Archiving (into .tars). The actual logfiles are accessed through an SSH, so I have used the following EXPECT sub-script within my main BASH... (8 Replies)
Hi Forum.
I have a script that accepts 3 input parameters (source directory, list file text, sleep time) and checks for the presence of files. If not there, script goes to sleep for certain amount of time provided by 3rd input.
list file text contains 1 entry but may contain more (file... (13 Replies)
I would want to run a code for 1 min and if it doesnt succeed in 1 min..I would want to exit it..I am using the following code...But the script is not going into my code part.It is waiting for 60 secs and then getting killed.
The code which is in the while loop actually takes less than 60 secs...... (6 Replies)
This is a very crude attempt in Bash at something that I needed but didn't seem to find in the 'sleep' command. However, I would like to be able to do it without the need for the temp file. Please go easy on me if this is already possible in some other way:
How many times have you used the... (5 Replies)
Hi,
if I have a lot of files like (AABBCC0010, AABBCC0011, AABBCC0012....AABBCC1000), can I write a small script to check any sequence number jump and show me the result which sequence number?
#The first sequence may start from 0010 or 0101... :confused:
Thank you!! (10 Replies)