Skip to content

Instantly share code, notes, and snippets.

@niltonvasques
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save niltonvasques/45ab43d8137b1cc1e2d1 to your computer and use it in GitHub Desktop.

Select an option

Save niltonvasques/45ab43d8137b1cc1e2d1 to your computer and use it in GitHub Desktop.
Logging infos about a process
gedit &
PID=$!
while :; do
sleep 3
ps -up $PID
echo "... get info about"$PID
done
@Marinofull
Copy link

what supposed should this do?

foo@foobar ~ $ ./process-info.sh 
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
foo+  3345  9.3  0.5 575256 22280 pts/0    Sl+  21:00   0:00 gedit
... get info about7070
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
foo+  3345  8.5  0.6 1200520 25288 pts/0   Sl+  21:00   0:00 gedit
... get info about7070
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
... get info about7070
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
... get info about7070
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
... get info about7070
^C

I had to abort, after close the gedit.
in each 3 seconds it gives me the result for ps -up PID, but the file log.txt does not exist.

@Marinofull
Copy link

did you remove the freaking line log? 😒

@niltonvasques
Copy link
Author

Why you expect a log.txt file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment