LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 11-01-2008, 12:20 AM   #1
Golgo13
LQ Newbie
 
Registered: Jan 2008
Posts: 6

Rep: Reputation: 0
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
 
Old 11-01-2008, 05:57 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,744
Blog Entries: 54

Rep: Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973Reputation: 2973
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?
 
Old 11-01-2008, 08:54 AM   #3
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
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).
 
Old 11-02-2008, 04:30 AM   #4
ramesh.mimit
LQ Newbie
 
Registered: Nov 2006
Posts: 26

Rep: Reputation: 15
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 }'
 
Old 11-02-2008, 04:54 AM   #5
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
Quote:
Originally Posted by ramesh.mimit View Post
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.
 
Old 11-02-2008, 05:07 AM   #6
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
I'd start here

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help: using cron + my bash script --> don't want mail from script beeblequix Linux - General 7 11-23-2007 10:25 PM
bash script to send a mail attachment aeby Linux - General 6 05-28-2007 07:13 AM
bash script to send mail Cruger Programming 1 03-06-2004 09:25 AM
Need help finishing Bash Script to add new user and map virtual e-mail info. O_Chaos Linux - Newbie 1 02-09-2004 05:06 PM
bash script, for deleting a specefic mail sn0wman Programming 8 01-16-2004 07:20 PM


All times are GMT -5. The time now is 10:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration