Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Apr 212010
 

Best way to kill all child processes forked by a given program

Answer:

Firstly, find the process group leader (i.e. master process that forked other processes) of the program, e.g. apache2

# sudo ps x -o  "%p %r %y %x %c " | grep apache2 

14787 14787 ?        00:00:00 apache2

To verify if it is the process leader.

# pgrep apache2 | sort -n | head -n1 
14787 

To issue kill to all the members in the process group

# kill -9 -14787

Apr 102010
 

Rescheduling mlocate to run weekly instead of daily

Answer:

As explained before, mlocate is a useful tool for quickly find files on the filesystem based on their name.

When you installed the mlocate, it created a daily cron job under /etc/cron.daily/ which build the database daily. However, it is quite IO intensive when you build the database, and it is not recommended to run the indexing in a production server in such high frequency...it is better to run it weekly or monthly.

E.g. To reschedule the the cron job to run weekly

# mv /etc/cron.daily/mlocate /etc/cron.weekly/