script to display memory/cpu usage periodically
Hi, I am a newbie here.
How do we display the memory and cpu usage continuously on Linux target, I can do cat /proc/meminfo , or free and similar commands, but how can I run them like for every 1sec/ 2sec etc. I don't have support of watch command. |
top, or do a while script,
just a showing of what can be done. Code:
#!/usr/bin/env bash Depending on what desktop / window manager too, most all have there own plugins for these things. |
Quote:
sleep utility is disabled for my target, its not in my hand to implement sleep utility, can it be done without sleep? |
Quote:
|
Quote:
may be I will have to ask for sleep utility, if its cannot be done other way.. |
Quote:
Quote:
|
Maybe:
Code:
#!/bin/sh |
Looks like you do not have many tools to work with,
there is this little trick that is done in programming by running a loop with an astronomical (ball park) number to get the loop to count up to. This is using a loop to create a wait state before moving on. The operator/programmer just needs to work out the "magic" number needed to get the loop to count to in order to get the desired time limit needed. Code:
#!/usr/bin/env bash |
Is ping enabled?
If you have ping then you can ping localhost (or maybe even 0.0.0.0 not sure) for a "sleep" replacement. Default time between pings is one second, and if you wanted to wait five seconds, then you'd do six pings (since the first is 'immediate'), like this: Code:
ping -c 6 127.0.0.1 Code:
ping -c 11 127.0.0.1 |
Since you're apparently working with a very stripped down set of tools, it would be helpful to know what commands you do have access to.
EDIT: There are several alternatives to wait without the sleep command listed in this Stack Exchange thread. |
I just happnen to be in FreeBSD now, but yeah 'at'
Code:
[userx@FreeBSD ~]$ echo "HIeoolo at me boy" | at 07:38 Which looks to be problematic. 'at' would have to be put into a loop then that loop got to have a means to be put to sleep or something before it calls 'at' again to set a new time to output information. It does keep a log though. |
All times are GMT -5. The time now is 07:15 AM. |