i developed a script to measure the uptime of a process in a Solaris 10/11 environments.
All is well, but i came across a situation where there are multiple processes of the same name. Basically i have the following result file:
Where first column is the process name, followed by it's pid and the uptime in seconds.
i am trying to find a way to get the uptime vs. an if condition (by a loop?) where if the uptime is less then say 3600 seconds it outputs the process and it's pid on the same line.
Bascially i tried:
Where $TIME contains only the 3rd column, i.e. the uptime, but it's not working as it should.
$CRONOUTFILE is the output file as shown above.
What i am trying to achieve is to output only the process and pid in a similar output:
Critical - the following processes $PROCESS are less then $CRITICAL_SIZE - $PID:$TIME, $PID:$TIME...,$PID:$TIME
Where the $PROCESS can be easily set an argument in the script.
I am totally confused in using the for loops or the while loop. May you kindly give me some hints?
Hello,
I'm using RHEL 5.1 with bash. How to handle "read" inside while loop reading every line? Please see below:
# cat /tmp/passwd_sample
CARRJ12:qVSn4ja4mFA72,..:20021:125:JULIAN CARR:/home/everyone:/bin/bash
HERCOT01:NK/3j2ZB4ZC7Q:20022:125:TOM HERCOCK:/home/everyone:/bin/bash... (4 Replies)
I have files in the ABC_YYYYMMDD.zip format under a directory. Each zip file contains A text file in the ABC_YYYYMMDD.txt format.
I am trying to create a script that will Rename the zip files and their underlying text file replacing the datepart in them with .
For eg: in the case of... (1 Reply)
Hi ,
I'm using Ksh 88 version.
I've a text file which contains the directory names
DIR1
DIR2
----
DIR10
I've to remove the data which has more that 30 days from the above directories .
The data has to be removed from the following path
cd /home/etc/DIR1/hist
cd /home/etc/DIR2/hist... (2 Replies)
Hi,
I want to read file multiple times. Right now i am using while loop but that is not working.
ex.
While read line
do
while read line2
do
echo stmt1
#processing some data based on data.,
done < file2.txt
done < file1.txt # This will have 10... (4 Replies)
until
do
read -p "Invalid cars. Try againa" cars1
done
Ok i have the above code, im getting users input and if it doesnt match in the file the user has to try again untill its correct
But when i run this it gives me an error saying
./Cars.bash: line 43: (2 Replies)
Hi,
I have a text file with multiple lines, each having data in the below format <DOB>,<ADDRESS>
I have to write a script which reads each line in the text file in loop, assign the values to these variables and do some further processing in it.
Using the following code prints the values... (12 Replies)
Hi,
I have a text file with multiple lines, each having data in the below format
<DOB>,<ADDRESS>
I have to write a script which reads each line in the text file in loop, assign the values to these variables and do some further processing in it.
Using the following code prints the... (1 Reply)
Hi all,
I've got 2 files.
File 1 has a list say
a
b
c
d
e
f
File 2 got
start=
What I want is to create File 3 which look like this
start=a,b,c,d,e,f
So is it possible to loop throught File1 to echo it into File3 in one line? (3 Replies)
Hi Frdz
while read line
do
name=`echo $line | cut -d' ' -f 1 `
password=`echo $line | cut -d`-` -f 2`
name > logfile.txt
password > logfile.txt
done < list.txt
When it is run, am getting last values in list.txt file only,it is not storing lall the list entry values. How can i... (5 Replies)
Hi all
I have two file that contain different data.I want to get each file data line by line in one loop.i try with cat but cat works ok against one file
File a
23
34
45
File b
abc
xyz
cgh
now i want like this in a loop.Below is just example.i am doing some thing smiler.can any... (3 Replies)