0

Can someone tell how to submit a one liner command using nbq command line? Submitted multiple commands in Linux works fine but not in nbq mode as below.

find /nfs/disks/test_dir/ -name .snapshot -prune -o -printf '%s %p\n'" | sort -nr | head -n 50 | tee log

this works just find in Linux capturing the top 50 files in the check area.

nbq -P <pool> -q <slot> -c <machine> -J <logfile> --task-name checkdisk find /nfs/disks/test_dir/ -name .snapshot -prune -o -printf '%s %p\n'" | sort -nr | head -n 50 | tee log

failed as it just executing the first part without recognizing the pipe.

3
  • 2
    Could you please add link to what nbq is [supposed to mean]?
    – user86969
    Commented Jun 10, 2016 at 7:25
  • nbq is the netbatch command to trigger netbatch job.
    – Grace
    Commented Jun 10, 2016 at 7:59
  • 1
    Both commands have a mis-matched " before the first pipe. Are those definitely what you're executing?
    – JigglyNaga
    Commented Jun 10, 2016 at 12:00

1 Answer 1

0

When you run that whole nbq ... find ... | sort ..., pipeline, the shell splits the commands up as follows:

nbq -P <pool> -q <slot> -c <machine> -J <logfile> --task-name checkdisk find /nfs/disks/test_dir/ -name .snapshot -prune -o -printf '%s %p\n' | 
 sort -nr |
 head -n 50 |
 tee log

So the only thing that nbq sees is the bit before the first pipe. You need to stop the shell from doing that, and instead give the whole line to nbq. Without any documentation about how nbq parses and runs the command, it's difficult to know the right approach.

  • You could tell nbq to execute a shell sh, with your original one-liner as a single argument:

    nbq -P <pool> -q <slot> -c <machine> -J <logfile> --task-name checkdisk \
      sh -c "find /nfs/disks/test_dir/ -name .snapshot -prune -o -printf '%s %p\n' | sort -nr | head -n 50 | tee log"
    
  • Alternatively, nbq may be clever enough to manage the pipeline itself (or, more likely, start another shell to do the work), in which case you only need to escape each | to protect it from the (current) shell.

    nbq -P <pool> -q <slot> -c <machine> -J <logfile> --task-name checkdisk \
      find /nfs/disks/test_dir/ -name .snapshot -prune -o -printf '%s %p\n' \| sort -nr \| head -n 50 \| tee log
    
  • If all else fails, you could abandon the "one-liner" approach, and put the whole pipeline in a script:

    #!/bin/sh
    find /nfs/disks/test_dir/ -name .snapshot -prune -o -printf '%s %p\n' |
      sort -nr |
      head -n 50 |
      tee log
    

    then tell nbq to run that script instead:

    nbq -P <pool> -q <slot> -c <machine> -J <logfile> --task-name checkdisk \
      /path/to/top50.sh
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .