Posts Tagged email

Quick Hack: delete bulk processes reported with ps/grep.

Having qmail running on multiple machines (I know there are better alternatives) we often have to go in and clean up after a crashed qmail service so it will behave again for a while.

Here is a quick and dirty hack to kill processes up that are there when you do a ps aux | grep <process name>

SEARCH='qmail' ; ps -eo pid,cmd | grep $SEARCH | awk '{ print $1 }' | xargs -I pid kill -15 pid

This uses ps and grep to find the processes and awk and xargs to create and execute the kill command for the PID of that process.

This command can easily be adapted to search for whatever process is required by changing the string in the SEARCH variable at the start of the command. The command above is designed as a follow up to using a ps aux | grep to find the search string that identifies the process.

Check out a quick howto on xargs here. I think it is one of the must for all hardcore Linux sys admins out there.

Tags: , , , , , , , ,

Mark all messages as Read in Gmail.

I have an issue where I get slack with my email and do not stay on top of things. Especially in accounts where I get a lot of mailing list traffic. I wanted to clean out a whole heap of this and found a really quick way to make use of the filters in Gmail to mark the messages.

It is really simple.

Goto ‘Create a filter’ which is next to the search bar.

In the ‘Has the words’ section add in is:unread

When you hit next you will be prompted with the dialogue box bellow.

Gmail filter dialog box

Click ‘Ok’ on the dialogue box and move on to the next screen.

Select the ‘Mark as read’ tick box as well as the ‘Also apply filter to’ tick box next to the ‘Create filter’ button.

And there you are done. Don’t forget to go through and delete the filter afterwards as if you don’t all mail will hit your inbox and be marked as read.

I found this on Lifehacker which is an awesome site and well worth following.

Tags: , ,

Plesk: How to count SMTP connections per email account.

Found an interesting solution for users of plesk/qmail for how to identify a user who is abusing your authenticated SMTP service.

Running the command:

cat /var/log/messages | grep -i smtp_auth | grep "logged in" | awk {' print $11 '} | awk -F / {' print $6"@"$5 '} | sort | uniq -c | sort -n | tail

or:

cat /var/log/syslog | grep -i smtp_auth | grep "logged in" | awk {' print $11 '} | awk -F / {' print $6"@"$5 '} | sort | uniq -c | sort -n | tail

Depending on your Linux Distro and you will get an output like the example bellow:

7 user@example.com
7 someone@spamewhere.net.au
8 stuff@onthenet.com.au
8919 user@crackeddomain.com.au

As you can see the account ‘user’ for the domain ‘crackeddomain.com.au’ are having unusually high amounts of SMTP connections for an account.

This is useful for tracking bulk email being sent through your system or hijacked accounts being used by spammers.

I found this on rackerhacker.com a site by Senior Rackspace Systems Engineer Major Hayden, go and check it out it is full of awesome content.

Tags: , , , , , ,