LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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
 
LinkBack Search this Thread
Old 06-05-2009, 05:24 AM   #1
rajesh.bahl
Member
 
Registered: Jan 2007
Posts: 95

Rep: Reputation: 15
Need Help in constructing a script


Am using postfix running on CentOS 5.3. It has the "always_bcc" function enabled for backup of the mails. The "mailbox_size_limit" is set to 1GB.

When this limit for "backup" is reached, the system starts giving error and we transfer the contents of this "backup file" which is /var/spool/mail/backup to some other file and make this as an empty file to start over again.

I need to automate the whole process in the sense that the system should check for the size of /var/spool/mail/backup file every one hour and when the size reaches to 1GB, it should execute the commands as:

service postfix stop
cp /var/spool/mail/backup /home/backup/<some_name>
> /var/spool/mail/backup
service postfix start

I am not having much idea about shell scripting - Can any one help in constructing such a script ?



thanking in advance
rajesh.bahl
 
Old 06-05-2009, 02:32 PM   #2
tsg
Member
 
Registered: Mar 2008
Posts: 155

Rep: Reputation: 30
Here's part of a script I wrote for rotating and compressing logs based on a file size limit. It might give you a good starting point.

Code:
#!/bin/bash

SIZELIMIT=1000000000

FILESIZE=`stat -c%s $x`;
if [[ $FILESIZE -gt $SIZELIMIT ]]; then
	# stop the service, backup the log, restart the service
fi
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help in constructing a Script rajesh.bahl Linux - Security 1 06-05-2009 06:08 AM
How to get full path to script file inside script itself? And in case of sym links? maggus Linux - Newbie 3 05-28-2009 09:40 AM
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 12:33 PM
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 05:19 AM
constructing a beowolf cluster Goatdemon Linux - General 16 12-31-2005 12:30 PM


All times are GMT -5. The time now is 01:02 PM.

Main Menu
 
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
Open Source Consulting | Domain Registration