ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 am sure there are other things out there that give this info, I do not really worry about it so, yeah, there are others out there I am sure that can give you more info.
Depending on what desktop / window manager too, most all have there own plugins for these things.
I am sure there are other things out there that give this info, I do not really worry about it so, yeah, there are others out there I am sure that can give you more info.
Depending on what desktop / window manager too, most all have there own plugins for these things.
sleep utility is disabled for my target, its not in my hand to implement sleep utility, can it be done without sleep?
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
while true
do
for (( i=0;$i<9999;i++))
do
((c++)) #give it something to do
#when it hits the magic number it will
#exit loop preform operations below
#then start over doing this again
done
echo "Mem free"
awk '/MemFree:/ {print $2 $3}' /proc/meminfo
echo "MemAvailable:"
awk '/MemAvailable:/ {print $2 $3}' /proc/meminfo
c=0 #this has no need other then to give the
#the for loop something to do while it
#is counting up to x amount in the (( ))
done
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
If you wanted to wait 10 seconds:
Code:
ping -c 11 127.0.0.1
So the count, on default settings otherwise, is seconds + 1.
I just happnen to be in FreeBSD now, but yeah 'at'
Code:
[userx@FreeBSD ~]$ echo "HIeoolo at me boy" | at 07:38
at: you do not have permission to use this program
[userx@FreeBSD ~]$ sudo echo "HIeoolo at me boy" | at 07:38
at: you do not have permission to use this program
[userx@FreeBSD ~]$ whereis at
at: /usr/bin/at /usr/share/man/man1/at.1.gz /usr/src/usr.bin/at
[userx@FreeBSD ~]$ su
Password:
[root@FreeBSD /home/userx]# echo "HIeoolo at me boy" | at 07:45
Job 1 will be executed using /bin/sh
[root@FreeBSD /home/userx]#
root login might too be needed in Linux to use at. Then there is the repeat 'at' to be worked out to make 'at' fire off every x amount until shut down.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.