Just paste to a shell. What I wrote was a command and script.
I made a file out of it to allow me to rerun it etc. The output goes to the shell, but after a while it gets too long and one cannot scroll up to copy it all. Thus my need for a file output.
Where did I lose you?
You didn't, bar my total non-clue about perl.
The script is between the pair of single quotes. The required argument is the pid. The "$(pid of inkscape)" bit is just bash backticks (but the $() form nests, so that's my habit.)
I got that.
perl -e 'my $pid = shift; while(1) { open(my $fh, "<", "/proc/$pid/statm") or die; my $data = <$fh>; chomp($data); print join(" ", time,map({$_ * 4} split(/ /, $data))), "\n"; sleep(1); }' $(pidof inkscape) > logfile
Does not work. I actually tried this one too. The logfile is blank. I tried >> as well, to no avail.
Or, if you want to put it in a file:
#!/usr/bin/perl # track_memory.pl my $pid = shift(@ARGV); while(1) { # read the proc data open(my $fh, "<", "/proc/$pid/statm") or die; my $data = readline($fh); chomp($data); # prepend the time and multiply blocks by 4KB print join(" ", time(), map({$_ * 4} split(/ /, $data) ) ), "\n"; sleep(1); }
Results in: scripts:$ ./eric2log $(pidof inkscape) > logfile ./eric2log: line 3: syntax error near unexpected token `(' ./eric2log: line 3: ` my $pid = shift(@ARGV);'
Sorry to be dense about this. Thx for the continued patience :)
/d