سؤال

I want to create a keeper on my jobs file on the HPC in the campus. Should my disk usage exceed 50GB I want all my jobs to stop (and possibly get an email about this). What I want to do is something of this sort:

#!/bin/bash

run=1
while [ $run -gt 0 ]; do
  a=du -sh ~
  if [ $a -gt 50GB ]; then
    run=0
    break
  fi
done

qdel j*fd
qdel j*fd
#send email in some way

I am stuck in two things:

  1. I can't use du -sh inside a script, I get an error:

    -sh: command not found

  2. I don't how to compare the sizes.

how can I achieve this?

هل كانت مفيدة؟

المحلول

  1. a=$(du_command). a=du -sh ~ is equivalent to -sh ~ with environment variable a=du

  2. compare size in kb : a=$(du -sk ~ | awk '{print$1}') and [ ${a} -gt 51200 ]

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top