python - kill a user's program if disk usage exceeds 98% in linux -


i know can find amount of space left in home directory using 'df -h' in linux. possible write script/python program monitors disk usage in home directory , kills running programs user name if disk usage exceeds 98%. using ubuntu 12.04 server

instead of lurking, adding space usage on , on (which requires repeated scans of entire home directory hierarchy) , killing processes, should set disk quota. if programs out of hand, os choke access disk , won't have thing.

or if it's particular program writing single file gets out of hand, can use ulimit -f cap size of files can create. (see help ulimit @ bash prompt.)