On Sun, Oct 7, 2018 at 12:40 PM Stanislav Levin <[email protected]> wrote:

> Could somebody advise me is it possible to check a disk/directory free
> space before job run?
>
> There are memory, CPU job limitations, but not a disk.

--limit is made for you.

This should work:

disk() {
  # Input: Pause_MB Kill_MB
  # Returns:
  #   exit val = 0 if 'df .' > Pause_MB
  #   exit val = 1 if 'df .' > Kill_MB
  #   exit val = 2 otherwise
  PauseMB=$1
  KillMB=$2
  exit $(df -k .|
           perl -ane '2..3 and print $F[3]>'$PauseMB'000 ? 0 :
                        $F[3] > '$KillMB'000 ? 1:2,"\n"');
}
export -f disk
parallel --limit 'disk 10000 8000' -v sleep ::: {1..100}


/Ole

Reply via email to