Home > Uncategorized > Drop multiple processes into the background

Drop multiple processes into the background

This is great for multiple log tailing.

find /var/log/httpd -type f -exec tail -f {} + &

note that when I presented an alternate using find and xargs in ##linux on freenode, a dude pointed out “what if someone creates a file called ‘;rm -rf .’?” Nasty things, that’s what.

Then kill all tails with:

ps -f | grep tail | awk '{print $2}' | xargs kill

I would like to say that you could use `jobs -p` and pipe that directly into `xargs kill`, but it seems that the PID of the `job` itself is `jobs -p`+1.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: