LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Bash script for mail quotas (http://www.linuxquestions.org/questions/linux-server-73/bash-script-for-mail-quotas-680394/)

Golgo13 10-31-2008 11:20 PM

Bash script for mail quotas
 
Hello, i am not sure if this is the right forum - forgive me but I am trying to create a bash script to get a list of all users on my server with more than 100MB of mail. (Mail is kept in /home/username/Mail/ for each user.)

How would I be able to do that?

Thank you!

golgo13

unSpawn 11-01-2008 04:57 AM

If you want a ready-made then better ask for it, else maybe ponder these questions to help you learn how to do it yourself?
How do you produce (or find) a list of directories (one level deep) in a directory?
What is the command to find out the disk usage of a directory?
What are the easiest ways to cut space-separated values?
What, in shell scripts, are the easiest ways to find if one of a set of two values is equal or bigger than the other?

Disillusionist 11-01-2008 07:54 AM

man I wish I knew how to get to the documentation.

If you need help, please post what you have written so far (enclosed in CODE tags).

ramesh.mimit 11-02-2008 03:30 AM

You can simply run the follwing command to find the users having more than 100MB of mailbox

cd /home/Users/

ls -l * | awk -F\ '{if ($4 > 104857600) print $7 }'

Disillusionist 11-02-2008 03:54 AM

Quote:

Originally Posted by ramesh.mimit (Post 3328914)
You can simply run the follwing command to find the users having more than 100MB of mailbox

cd /home/Users/

ls -l * | awk -F\ '{if ($4 > 104857600) print $7 }'

I think you missed the point.

The OP has stated that mail is stored in each users home directory in a subfolder called Mail.

This folder will contain more than one file, but if the total of these files is over 100MB he wants to know about it.

Therefore he would need to:
  1. Get a list of all users with a Mail folder
  2. check how much disk space that folder is using
  3. compare that value with a pre-stated maximum
  4. print anything that is more than the pre-stated maximum

This is not that difficult but we should not do all the work for the OP.

If the OP posts what code he has written, we will offer suggestions for where we believe he has gone wrong.

billymayday 11-02-2008 04:07 AM

I'd start here

Code:

du --max-depth=2 /home | grep /Mail
Just a titbit


All times are GMT -5. The time now is 11:18 AM.