LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-19-2006, 02:16 PM   #1
etam
LQ Newbie
 
Registered: Oct 2006
Posts: 3

Rep: Reputation: 0
simple script


anyone help me to make a script that every 30 sec check the queue of postfix and if there are mail in it run postfix flush?

thank you
 
Old 11-19-2006, 05:37 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Easy enough..

Code:
#!/bin/bash
# Script to run postfix flush if Mail queue is not empty.

if [ -z "`/usr/bin/mailq | grep "Mail queue is empty"`"]; then
    /usr/sbin/postfix flush
fi
Save your script and make it executable:

Code:
chmod +x scriptname
Then add this script to run from cron every 30 seconds, which is actually limited by minutes but crond will usually check every 30 seconds, probably best to just leave at every minute, make the 1 a * if you want it to possibly run ever 30 seconds.

Code:
1 * * * * /path/to/script
 
  


Reply



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
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
simple script help!! Please kb100 Programming 4 08-18-2006 06:37 AM
Need help with a simple script shell script WindowBreaker Linux - Software 2 12-15-2005 12:45 PM
A very simple script roopunix Linux - Networking 3 05-28-2004 05:30 AM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:11 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
Open Source Consulting | Domain Registration