Problem creating a script using Rss for total consumption memory
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Problem creating a script using Rss for total consumption memory
Hi,
i want to create a script that opens firefox,loads some urls from a txt file and then record some statistics such as the amount of instances that belongs to firefox and the total memory consumption(in MB) every 0.5 sec.i want the statistics to be written and saved in file.i know how to find the memory consumption ( grep /proc/"pid"/status VmRSS ) but i dont know how to do it every 0,5 sec and then write&save on file.
There is a utility named "watch" which you can use to run your script every 0.5 seconds. See its manual page for the details. You can write the output to a file using a redirection
But to convert it to RSS needs a bit more work, maybe with perl.
Thank you for your answer,but maybe you misundestood me.With Rss i mean Resident set size,not rss feed.if you can help me now i would appreciate it
"help me NOW???"
How about reading the "Question Guidelines" first?? We will be glad to help you...but if you want it 'now', then you need to hire someone. We volunteer our time here, so telling us to help you 'now' is plain rude. Also, 'help' means that YOU do work, and tell us where you're stuck, not post what you want and expect us to hand you a script.
How about reading the "Question Guidelines" first?? We will be glad to help you...but if you want it 'now', then you need to hire someone. We volunteer our time here, so telling us to help you 'now' is plain rude. Also, 'help' means that YOU do work, and tell us where you're stuck, not post what you want and expect us to hand you a script.
Sorry,i didnt mean that.i dont mean "now" as you think.(figure of speech)My fault,i didnt expressed it well.
Do you want to start firefox,open the URLS,then shut firefox down completely every .5 second?
i want to start firefox,open urls for txt file,create list with all pids of firefox,kill instances(all these on background) and i want to create a recording statistics function(or if you know a better way) that every 0.5 sec will create a list with the amount of instances that belong to firefox and the total consumption memory(with resident set size),and these data must be saved on a output file.
i am stuck on the last part with the recording function.Basically i dont know how to do it every 0.5 sec.
Thank you for your time
Last edited by nuclear95; 11-21-2016 at 12:41 PM.
Reason: expand
i want to start firefox,open urls for txt file,create list with all pids of firefox,kill instances(all these on background) and i want to create a recording statistics function(or if you know a better way) that every 0.5 sec will create a list with the amount of instances that belong to firefox and the total consumption memory(with resident set size),and these data must be saved on a output file.
i am stuck on the last part with the recording function.Basically i dont know how to do it every 0.5 sec.
Thank you for your time
No problem...so, as asked previously; post what you have already done/written/tried, and we can assist.
There is a utility named "watch" which you can use to run your script every 0.5 seconds. See its manual page for the details. You can write the output to a file using a redirection
But to convert it to RSS needs a bit more work, maybe with perl.
Quote:
Originally Posted by Turbocapitalist
Ok. How far have you gotten with "watch" and redirecting its output to a file?
Quote:
Originally Posted by nuclear95
i want to start firefox,open urls for txt file,create list with all pids of firefox,kill instances(all these on background) and i want to create a recording statistics function(or if you know a better way) that every 0.5 sec will create a list with the amount of instances that belong to firefox and the total consumption memory(with resident set size),and these data must be saved on a output file.
i am stuck on the last part with the recording function.Basically i dont know how to do it every 0.5 sec.
Thank you for your time
Hi nuclear95, and welcome to LQ.
Can you please post some example output and illustrate what you have tried which gets you to this output. Please also update and indicate if you have tried the advice from Turbocapitalist?
Please note that it is difficult for persons to offer assistance for your problem if it appears that you are doing different attempts from the advice, we then have no idea which actions you are trying versus not.
Turbocapitalist also gave you a link for redirection which will help you with channeling the output of your command into a log file.
However if you have used a different command, or are writing a program to perform these actions, we have no real idea because you aren't posting any specifics about your attempts.
Capturing the pid of 'sleep 10s' instead of the firefox command? Seems like if you wanted a pid list, you would create it in the loop so you capture each pid created.
#Read the file by line
while read line; do
#Will open URL in a tab (background it)
firefox --new-tab "$line" &
#Sleep between tab open
sleep 2
#Find number of firefox PID's running, will be 1 with tabs.
pgrep firefox | wc -l >> stats.txt
#RAM stats to file
free -t >> stats.txt
#Seperatpr
echo "------New Tab------" >> stats.txt
#File to read
done < /home/zografos/Desktop/urls.txt
Leave out --new-tab if you want to open a new instance of firefox each time. Add whatever else you want in that loop.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.