I know I can find the amount of space left in my home directory using 'df -h' in linux. But is it possible to write a script/python program which constantly monitors disk usage in my home directory and kills all currently running programs with my user name if my disk usage exceeds 98%. I am using Ubuntu 12.04 server
Instead of lurking, adding up space usage over and over (which requires repeated scans of your entire home directory hierarchy) and killing all your processes, you should just set yourself up with a disk quota. If your programs get out of hand, the OS will choke their access to the disk and you won't have to do a thing.
Or if it's a particular program writing to a single file that gets out of hand, you can use
ulimit -f to cap the size of the files it can create. (See
help ulimit at the