- remove
| grep pythonif you want all processes - replace
2**10with2**20andMBwithGBif you want GBs instead of MBs - replace
pythonwith another string that your program starts with. You can inspect the output ofps auxcto see what's the 10th (0-indexed) column says in case you get no output. a python program could be running with the name of the python script and not python itself for example, so make sure to use the name of the script instead. - replace
%0.3fwith%0.2fif you want only 2 decimals for MBs - replace
watch -n 0.5withwatch -n 3if you want to refresh every 3 seconds - these were tested with bash 5.1.16 - should work with most recent bash versions
- if you tweak the
psflags in these examples the count of columns may change and the scripts may break.
- replace
2**10with2**20andMBwithGBif you want GBs instead of MBs - replace
pythonwith another string that your program starts with. You can inspect the output ofps auxcto see what's the 10th (0-indexed) column says in case you get no output. a python program could be running with the name of the python script and not python itself for example, so make sure to use the name of the script instead. - replace
%0.3fwith%0.2fif you want only 2 decimals for MBs - replace
watch -n 0.5withwatch -n 3if you want to refresh every 3 seconds - these were tested with bash 5.1.16 - should work with most recent bash versions
- if you tweak the
psflags in these examples the count of columns may change and the scripts may break.
- remove
| grep pythonif you want all processes - replace
2**10with2**20andMBwithGBif you want GBs instead of MBs - replace
pythonwith another string that your program starts with. You can inspect the output ofps auxcto see what's the 10th (0-indexed) column says in case you get no output. a python program could be running with the name of the python script and not python itself for example, so make sure to use the name of the script instead. - replace
%0.3fwith%0.2fif you want only 2 decimals for MBs - replace
watch -n 0.5withwatch -n 3if you want to refresh every 3 seconds - these were tested with bash 5.1.16 - should work with most recent bash versions
- if you tweak the
psflags in these examples the count of columns may change and the scripts may break.
The want is to display top like output but having RSS in MBs and I'm adding also a desire to filter out only the program I want.The want is to display top like output but having RSS in MBs and I'm adding also a desire to filter out only the program I want.
a. withoutWithout headers (if you memorizedps's headers)
One time:
ps auxc | grep python | perl -plae '$F[5]=sprintf q[%0.3fMB],$F[5]/2**10'2**10; $_=qq[@F]' | column -tUsing
watchto emulate like top, refreshing every 0.5 secwatch -n 0.5 $'ps auxc | grep python | perl -plae \'$F[5]=sprintf q[%0.3fMB],$F[5]/2**10\'2**10; $_=qq[@F]\' | column -t'Make an alias (bash 4.4 or higher)
alias watch-python=$'watch -n 0.5 \'ps auxc | | grep python | perl -plae "\$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10"2**10; \$_=qq[@F]" | column -t | grep python\''
b. withWith headers (for the rest of us):
One time:
(ps auxc | head -1; ps auxc | grep python | perl -plae '$F[5]=sprintf q[%0.3fMB],$F[5]/2**10'2**10; $_=qq[@F]') | column -tUsing
watchto emulate top, refreshing every 0.5 sec:watch -n 0.5 $'(ps auxc | head -1; ps auxc | grep python | perl -plae \'$F[5]=sprintf q[%0.3fMB],$F[5]/2**10\'2**10; $_=qq[@F]\') | column -t'Make an alias (bash 4.4 or higher)
alias watch-python=$'watch -n 0.5 \'(ps auxc | head -1; ps auxc | grep python | perl -plae "\$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10"2**10; \$_=qq[@F]") | column -t\''
The want is to display top like output but having RSS in MBs and I'm adding also a desire to filter out only the program I want.
a. without headers
One time:
ps auxc | grep python | perl -plae '$F[5]=sprintf q[%0.3fMB],$F[5]/2**10' | column -tUsing
watchto emulate like top, refreshing every 0.5 secwatch -n 0.5 $'ps auxc | grep python | perl -plae \'$F[5]=sprintf q[%0.3fMB],$F[5]/2**10\' | column -t'Make an alias (bash 4.4 or higher)
alias watch-python=$'watch -n 0.5 \'ps auxc | | grep python | perl -plae "\$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10" | column -t | grep python\''
b. with headers
One time:
(ps auxc | head -1; ps auxc | grep python | perl -plae '$F[5]=sprintf q[%0.3fMB],$F[5]/2**10') | column -tUsing
watchto emulate top, refreshing every 0.5 sec:watch -n 0.5 $'(ps auxc | head -1; ps auxc | grep python | perl -plae \'$F[5]=sprintf q[%0.3fMB],$F[5]/2**10\') | column -t'Make an alias (bash 4.4 or higher)
alias watch-python=$'watch -n 0.5 \'(ps auxc | head -1; ps auxc | grep python | perl -plae "\$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10") | column -t\''
The want is to display top like output but having RSS in MBs and I'm adding also a desire to filter out only the program I want.
a. Without headers (if you memorizedps's headers)
One time:
ps auxc | grep python | perl -plae '$F[5]=sprintf q[%0.3fMB],$F[5]/2**10; $_=qq[@F]' | column -tUsing
watchto emulate top, refreshing every 0.5 secwatch -n 0.5 $'ps auxc | grep python | perl -plae \'$F[5]=sprintf q[%0.3fMB],$F[5]/2**10; $_=qq[@F]\' | column -t'Make an alias (bash 4.4 or higher)
alias watch-python=$'watch -n 0.5 \'ps auxc | grep python | perl -plae "\$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10; \$_=qq[@F]" | column -t | grep python\''
b. With headers (for the rest of us):
One time:
(ps auxc | head -1; ps auxc | grep python | perl -plae '$F[5]=sprintf q[%0.3fMB],$F[5]/2**10; $_=qq[@F]') | column -tUsing
watchto emulate top, refreshing every 0.5 sec:watch -n 0.5 $'(ps auxc | head -1; ps auxc | grep python | perl -plae \'$F[5]=sprintf q[%0.3fMB],$F[5]/2**10; $_=qq[@F]\') | column -t'Make an alias (bash 4.4 or higher)
alias watch-python=$'watch -n 0.5 \'(ps auxc | head -1; ps auxc | grep python | perl -plae "\$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10; \$_=qq[@F]") | column -t\''
One time:
ps auxc | grep python | perl -laeplae '$F[4]=sprintf'$F[5]=sprintf q[%0.3fMB], $F[4]$F[5]/2**10; print qq[@F]'2**10' | column -t | grep pythonUsing
watchto emulate like top, refreshing every 0.5 secwatch -n 0.5 'ps$'ps auxc | grep python | perl -laeplae "\$F[4]=sprintf\'$F[5]=sprintf q[%0.3fMB], \$F[4]$F[5]/2**10;2**10\' print| qq[@F]"column -t'Make an alias (bash 4.4 or higher)
alias watch-python=$'watch -n 0.5 \'ps auxc | | grep python | perl -plae "\$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10" | column -t | grep python'python\''
One time:
(ps auxc | perlhead -ae1; 'pushps @x,qq[@F]auxc if| !@x;grep $F[5]=sprintfpython | perl -plae '$F[5]=sprintf q[%0.3fMB],$F[5]/2**10; push @x,qq[@F] if $F[10]=~/python/; END {$,=qq[\n]; print @x}'2**10') | column -tUsing
watchto emulate top, refreshing every 0.5 sec:watch -n 0.5 'ps$'(ps auxc | perlhead -ae "push @x,qq[@F]1; ifps !@x;;auxc \$F[5]=sprintf| q[%0.3fMB],\$F[5]/2**10;grep pushpython @x,qq[@F]| ifperl \$F[10]=~/python/;-plae END\'$F[5]=sprintf {\$q[%0.3fMB],=qq[\n]; print @x}"$F[5]/2**10\') | column -t'makeMake an alias (bash 4.4 or higher)
alias watch-python=$'watch -n 0.5 \'ps\'(ps auxc | perlhead -ae1; "pushps @x,qq[@F]auxc if| !@x;grep \$F[5]=sprintfpython | perl -plae "\$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10; push @x,qq[@F] if \$F[10]=~/python/; END {\$,=qq[\n]; print @x}"2**10") | column -t\''
- replace
2**10with2**20andMBwithGBif you want GBs instead of MBs - replace
pythonwith another string that your program starts with. You can inspect the output ofps auxcto see what's the 10th (0-indexed) column says in case you get no output. a python program could be running with the name of the python script and not python itself for example, so make sure to use the name of the script instead. - replace
%0.3fwith%0.2fif you want only 2 decimals for MBs - replace
watch -n 0.5withwatch -n 3if you want to refresh every 3 seconds - these were tested with bash 5.1.16 - should work with most recent bash versions
- if you tweak the
psflags in these examples the count of columns may change and the scripts may break.
One time:
ps auxc | perl -lae '$F[4]=sprintf q[%0.3fMB], $F[4]/2**10; print qq[@F]' | column -t | grep pythonUsing
watchto emulate like top, refreshing every 0.5 secwatch -n 0.5 'ps auxc | perl -lae "\$F[4]=sprintf q[%0.3fMB], \$F[4]/2**10; print qq[@F]" | column -t | grep python'
One time:
ps auxc | perl -ae 'push @x,qq[@F] if !@x; $F[5]=sprintf q[%0.3fMB],$F[5]/2**10; push @x,qq[@F] if $F[10]=~/python/; END {$,=qq[\n]; print @x}' | column -tUsing
watchto emulate top, refreshing every 0.5 sec:watch -n 0.5 'ps auxc | perl -ae "push @x,qq[@F] if !@x;; \$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10; push @x,qq[@F] if \$F[10]=~/python/; END {\$,=qq[\n]; print @x}" | column -t'make an alias (bash 4.4 or higher)
alias watch-python=$'watch -n 0.5 \'ps auxc | perl -ae "push @x,qq[@F] if !@x; \$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10; push @x,qq[@F] if \$F[10]=~/python/; END {\$,=qq[\n]; print @x}" | column -t\''
- replace
2**10with2**20andMBwithGBif you want GBs instead of MBs - replace
pythonwith another string that your program starts with. You can inspect the output ofps auxcto see what's the 10th (0-indexed) column says in case you get no output. a python program could be running with the name of the python script and not python itself for example, so make sure to use the name of the script instead. - replace
watch -n 0.5withwatch -n 3if you want to refresh every 3 seconds - these were tested with bash 5.1.16 - should work with most recent bash versions
- if you tweak the
psflags in these examples the count of columns may change and the scripts may break.
One time:
ps auxc | grep python | perl -plae '$F[5]=sprintf q[%0.3fMB],$F[5]/2**10' | column -tUsing
watchto emulate like top, refreshing every 0.5 secwatch -n 0.5 $'ps auxc | grep python | perl -plae \'$F[5]=sprintf q[%0.3fMB],$F[5]/2**10\' | column -t'Make an alias (bash 4.4 or higher)
alias watch-python=$'watch -n 0.5 \'ps auxc | | grep python | perl -plae "\$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10" | column -t | grep python\''
One time:
(ps auxc | head -1; ps auxc | grep python | perl -plae '$F[5]=sprintf q[%0.3fMB],$F[5]/2**10') | column -tUsing
watchto emulate top, refreshing every 0.5 sec:watch -n 0.5 $'(ps auxc | head -1; ps auxc | grep python | perl -plae \'$F[5]=sprintf q[%0.3fMB],$F[5]/2**10\') | column -t'Make an alias (bash 4.4 or higher)
alias watch-python=$'watch -n 0.5 \'(ps auxc | head -1; ps auxc | grep python | perl -plae "\$F[5]=sprintf q[%0.3fMB],\$F[5]/2**10") | column -t\''
- replace
2**10with2**20andMBwithGBif you want GBs instead of MBs - replace
pythonwith another string that your program starts with. You can inspect the output ofps auxcto see what's the 10th (0-indexed) column says in case you get no output. a python program could be running with the name of the python script and not python itself for example, so make sure to use the name of the script instead. - replace
%0.3fwith%0.2fif you want only 2 decimals for MBs - replace
watch -n 0.5withwatch -n 3if you want to refresh every 3 seconds - these were tested with bash 5.1.16 - should work with most recent bash versions
- if you tweak the
psflags in these examples the count of columns may change and the scripts may break.