Reputation: 10675
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:
I can't use du -sh inside a script, I get an error:
-sh: command not found
I don't how to compare the sizes.
how can I achieve this?
Upvotes: 0
Views: 5463
Reputation: 19305
a=$(du_command)
. a=du -sh ~
is equivalent to -sh ~
with environment variable a=du
compare size in kb : a=$(du -sk ~ | awk '{print$1}')
and [ ${a} -gt 51200 ]
Upvotes: 1