Sponsored Content
Full Discussion: Peak Ram Usage
Top Forums UNIX for Beginners Questions & Answers Peak Ram Usage Post 302983335 by bakunin on Monday 10th of October 2016 11:30:45 AM
Old 10-10-2016
Quote:
Originally Posted by dellanicholson
There are other issues with this program.
Yes.

I will point out the most obvious ones, but i wouldn't bet on having found all of them. The script is in a state which begs a rewrite anyway.

Code:
#!/bin/bash

You mentioned using AIX. The system shell is ksh, not bash. Use it!

Code:
Now=date + %M/%D/%Y

I suppose you want to use the date command to fill a variable there. This will fill the variable "Now" with the string "date" instead and the rest of the line will produce a syntax error. You do it this way (i have corrected the date-command too):

Code:
Now=$(date +"%M/%D/%Y")

Code:
while [[ -z $groups || -z $date1 || -z $n|| -z $email ]]; do

This is not ouright wrong, just dangerous. Suppose the variable groups has no content: this would leave the following command to be executed:

Code:
while [[ -z || -z $date1 || -z $n|| -z $email ]]; do

similar, if groups contains a space char:

Code:
while [[ -z foo bar || -z $date1 || -z $n|| -z $email ]]; do

and this, subsequently, will lead to a syntax error. If you query variables and their contents do it this way (notice the quoting):

Code:
while [[ -z "$groups" || -z "$date1" || -z "$n" || -z "$email" ]]; do

or, even more preferably, because being POSIX-compliant:

Code:
while [ -z "$groups" || -z "$date1" || -z "$n" || -z "$email" ] ; do

This will also not work:

Code:
 dialog --separate-widget $\n 
       --clear \

Notice the "n" at the end of the first line. When you continue a line with a backslash, it needs to be the absolutely last character in this line, because in fact you are escaping the following newline character with it. If there is another character (common problem: a space) after it, the backslash will escape that instead of the newline.

Code:
DISKINFO=tail -$n "/var/LV/$disk_'date +%Y.%H.%d'.txt"

Same as above, if you want a variable filled from a commands output you need to do it like this:

Code:
DISKINFO=$(tail -$n "/var/LV/$disk_$(date +"%Y.%H.%d").txt")


Code:
regex=/^[0-1][0-9]/[0-3][0-9]/[0-9]\{4\}$/
if [[$regex =~ date -d "$date1"]]

This won't work at all. First, "date -d" is not available in AIX (and in no other POSIX-compliant UNIX, because "-d" is not part of the POSIX standard). Since i cannot figure out what you are trying to achieve no suggestion for an alternative here, but explain what it should do and we probably find a solution.


Code:
if ! grep -q '$group' $DISKINFO ; then

almost correct. The problem is that variables ("$group") will not be expanded inside single quotes, only double quotes. And "grep" only works on files or streams, not on fixed strings:

Code:
if ! echo "$DISKINFO" | grep -q "$group" ; then


Finally: capitalisation is not arbitrary in UNIX. If a keyword is "else", it is supposed to be "else", not "Else", "ELSE" or anything else either (sorry for the pun). Likewise with all the other keywords: do, done, if, while, then, ...

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

RAM Physical Memory usage by each Process.

Hi All, I am trying to find the physical memory usage by each process/users. Can you please let me know how to get the memory usage?. Thanks, bsraj. (12 Replies)
Discussion started by: bsrajirs
12 Replies

2. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

3. UNIX for Dummies Questions & Answers

Command to check RAM usage

Hi Guys, How can i check the RAM usage for a particular user on the Linux machine. What command can be used. Thanks in advance, Swapna (1 Reply)
Discussion started by: Swapna173
1 Replies

4. Shell Programming and Scripting

RAM usage Information

Hi i just wanted to know what is the code to display amount of RAM and also the percentage used? I know i can possibly use the vmstat code but what part indicates the RAM? Any help would be much appreciated. Thanks (1 Reply)
Discussion started by: warlock129
1 Replies

5. Linux

Ram Usage

Hi one of our applications that runs on our Linux server leaks memory resulting in Ram that was used by the program not being released back to the operating system once a file has been processed. the result is over a very short period virtual all the memory has been used. an example currently ... (8 Replies)
Discussion started by: treds
8 Replies

6. Solaris

Server RAM Usage checkup & support

Hi RAM of my system is 24 GB however when i checked the processes pids and counted the memory usage by pmap i found out that the total memory usage is 36 GB It s obvious that my system might be using some of virtual memory or swap space . How can i check which memory it is using and how .. ... (9 Replies)
Discussion started by: Paarth
9 Replies

7. Red Hat

High RAM usage, extremely low swapping

Hi team I have three physical servers running on Red Hat Enterprise Linux Server release 6.2 with the following memory conditions: # cat /proc/meminfo | grep -i mem MemTotal: 8062888 kB MemFree: 184540 kB Shmem: 516 kB and the following swap conditions: ... (6 Replies)
Discussion started by: hedkandi
6 Replies

8. OS X (Apple)

RAM Usage discrepancy

Hey there! I'm a new user here who registered because I couldn't get these kind of questions answered in the place I directly com from. :o I've found a discrepancy in total RAM used and I can't figure out why it is. My only guess is there are some RAM used by some stuff impossible to identify,... (2 Replies)
Discussion started by: dasx
2 Replies

9. UNIX for Dummies Questions & Answers

Average CPU and RAM usage for a process

Hi, I will be creating a process myself and I want to know the average CPU and RAM used by the process over the lifetime of the process. I see that there are various tools available(pidstat) for doing , I was wondering if it possible to do it in a single command while creation. Thanks in... (3 Replies)
Discussion started by: koustubh
3 Replies

10. UNIX for Advanced & Expert Users

Ubuntu 14.04 - how to less ram usage

Hello, I have an ubuntu14.04 installed pc with 32GB ram. Operating System: Ubuntu 14.04.5 LTS Kernel: Linux 4.9.148-xxxx-std-ipv6-64 Architecture: x86_64 When I check free memory it shows: total used free shared buffers cached Mem: 31882 ... (2 Replies)
Discussion started by: baris35
2 Replies
All times are GMT -4. The time now is 09:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy