0

I am trying to get the maximum memory usage of my jobs in the cluster. here is my command

$ ls -lrt | awk '($5<800 && $7==2){print}' | grep -Eo ".o[0-9]+" | sed 's/\.o//g' | qacct -j | grep -w "maxvmem" | sort -rn | less

the output of the sed command won't pipe correctly into the qacct command.

instead of listing the memory usage of just the files I'm looking for, this pipeline shows all the memory usage of all the files in the directory.

Ruiyang Li
  • 94
  • 1
  • 8
  • Do you have reason to believe qacct is *supposed* to read from stdin (the stream a pipe connects to)? I don't see anything to that effect in its documentation. – Charles Duffy Aug 04 '18 at 02:06
  • It looks like you probably want `xargs qacct` (or, if input is line-oriented, `xargs -d $'\n' qacct`). We've got duplicates, then... – Charles Duffy Aug 04 '18 at 02:06
  • 1
    That said, see also [Why you shouldn't parse the output of `ls`](http://mywiki.wooledge.org/ParsingLs) – Charles Duffy Aug 04 '18 at 02:08
  • ...in general, the right tool to use to find files that match a criteria (and yes, you can filter by size and by modification date) is `find`. See [UsingFind](http://mywiki.wooledge.org/UsingFind), particularly including the "custom actions" section to see how to have `find` run `qacct`, and/or invoke a shell that in turn invokes `qacct` with modified arguments. – Charles Duffy Aug 04 '18 at 02:14

0 Answers0