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