-3

I'm trying to create a script that will monitor all non-admin user home directories under /HOME for growth of over 100MB in a 20 min period, and send an email to root if this occurs. The email needs to contain a list of users that were found in violation of this.

I'm rather new to Unix, and I can easily write pseudo code for this, but translating it into code is proving to be a difficulty. I'm thinking it would go something like this:

For (all folders under /HOME) {
   - store folder size in a variable
   - store current timestamp in a variable
   - when time += 20 min, get new folder size and compare
   if  (new size - old size > 100+)
       - send email notification to root with offending username
   else (exit)
}

Any help would be greatly appreciated! I'm really struggling with this.

  • 1
    Even if your pseudo-code was correct, this probably wouldn't protect against accidental or intentional denial of resources. Look into per user disk quotas and let the operating system prevent disk hogging. – msw Jul 30 '14 at 19:49

1 Answers1

1

You need to get the commands for

This was not hard to find, was it?

It might help you to know Difference between wait and sleep and how to deal with arrays

Community
  • 1
  • 1
martin
  • 3,149
  • 1
  • 24
  • 35