Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need a command, or something that runs as a cron job, that logs what IPs my machine is communicating with, what ports, and what process did it.

share|improve this question
Running something as a cron job means you will miss many connections. I'd suggest learning the ropes of auditd. – Deer Hunter May 9 '13 at 4:51
up vote 3 down vote accepted

Use Socket Stat:

ss -p

You might want to explore ss manpage for some more options, like -r to resolve ip addresses to domain name:

ss -pr

Another good tool is netstat, but I found ss command line invocation to be simpler with respect to the result you want.

share|improve this answer
ss is a linux specific utility. netstat is more widely available (but the options differ depending on OS). – jordanm May 8 '13 at 22:39
Right! Anyway, the OP was looking for a Linux solution, so ss is fine. – Stefano Sanfilippo May 8 '13 at 23:10

There are many tools and ways to do this but this is probably what you're looking for:


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.