Processes by uid in perl.

This is just a quick hack to find which uid owns how many processes on your system. Obviusly, this can be altered to just about anything, but it’s a good example of how perl can use Unix commands inside a script.

#!/usr/bin/perl -w

# Who owns how many processes

@pslist = qx/ps -ef/;

# Remove the header line
shift @pslist;

foreach $line (@pslist)
@splitline = split(" ",$line);
# Count usernames

foreach $user (sort keys (%count))
print "User $user owns $count{$user} processes \n";

One comment on “Processes by uid in perl.

  1. I enjoy what you guys are usually up too.

    This type of clever work and reporting! Keep
    up the very good works guys I’ve incorporated you guys to
    my own blogroll.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s