Monday, October 26, 2009

/usr/local/cpanel/base/horde/imp/lib/MIME/Viewer/plain.php on line 132

If you are getting following error while reading emails in Horde in cpanel + CentOS server then just reset horde with following command on shell with root access.

Error
====================================================

/usr/local/cpanel/base/horde/imp/lib/MIME/Viewer/plain.php on line 132
====================================================

Command
=========================================
/scripts/resethorde
=========================================

There seems to be be something wrong with latest cpanel upgrade.




Thursday, October 22, 2009

How to stop generating core files

You may come across core files which gets generated within your accounts . The possible reason for the core files getting generated is when a php process is killed, apache creates core files under your account .

On phpSuexec servers this may cause due to incorrect php.ini file placed in your account and if it is caused due to php/apache then you can get rid off those core files by editing the httpd startup file on the server end. Following are the steps to edit httpd startup file.

========================================================
root@server [~]#which httpd
/usr/sbin/httpd
root@server [~]# nano /usr/sbin/httpd

Search for ulimit lines .For eg : you can see these lines

ulimit -n 1024
ulimit -n 4096
ulimit -n 8192
ulimit -n 16384

You need to add ulimit -c 0 at the end .Which will look like :

ulimit -n 1024
ulimit -n 4096
ulimit -n 8192
ulimit -n 16384
ulimit -c 0


Save File


Restart httpd

root@server [~] /etc/init.d/httpd restart 
======================================================

Sunday, October 18, 2009

Effective way of killing zombie process

Here is a most effective way to find a zombie process and kill them
============================================
Execute following command on shell

#ps -el | grep Z

this will give you the zombie process data including its Parent Process ID (PPID), which we need to take care of.
#kill -9 PPID
where PPID is the Parent Process ID you got from the previous command.
============================================

How to kill zombie process automatically

Write a script and schedule as a cron job.

==================================
for each in `ps auxww | grep Z | grep -v PID | awk ‘{print $3}’`; do for every in `ps auxw | grep $each | grep cron | awk ‘{print $2}’`; do kill -9 $every; done; done
==================================

How to kill zombie process + CentOS + Cpanel

Execute following command on shell
=================================================================
# ps aux | awk '{ print $8 " " $2 }' | grep -w Z    or ps aux | awk '$8=="Z" { print $2 }'
Output is :
Z 1926
Z 4858
Z 3726


To kill a zombie
# kill -91926 4858 3726
===================================================================

Friday, October 16, 2009

What is Zombie process

A zombie process or defunct process is a process that has completed execution but still has an entry in the process table. This entry is still needed to allow the process that started the (now zombie) process to read its exit status. The term zombie process derives from the common definition of zombie—an undead person. In the term's colorful metaphor, the child process has died but has not yet been reaped. When a process ends, all of the memory and resources associated with it are deallocated so they can be used by other processes. However, the process's entry in the process table remains. The parent can read the child's exit status by executing the wait system call, at which stage the zombie is removed. The wait call may be executed in sequential code, but it is commonly executed in a handler for the SIGCHLD signal, which the parent receives whenever a child has died. After the zombie is removed, its process ID and entry in the process table can then be reused. However, if a parent fails to call wait, the zombie will be left in the process table. In some situations this may be desirable, for example if the parent creates another child process it ensures that it will not be allocated the same process ID. On modern UNIX-like systems (that comply with SUSv3 specification in this respect), the following special case applies: if the parent explicitly ignores SIGCHLD by setting its handler to SIG_IGN (rather than simply ignoring the signal by default) or has the SA_NOCLDWAIT flag set, all child exit status information will be discarded and no zombie processes will be left.

A zombie process is not the same as an orphan process. An orphan process is a process that is still executing, but whose parent has died. They do not become zombie processes; instead, they are adopted by init (process ID 1), which waits on its children.

Zombies can be identified in the output from the Linux ps command by the presence of a “Z” in the “STAT” column. Zombies that exist for more than a short period of time typically indicate a bug in the parent program, or just an uncommon decision to reap children (see example). As with other leaks, the presence of a few zombies is not worrisome in itself, but may indicate a problem that would grow serious under heavier loads. Since there is no memory allocated to zombie processes except for the process table entry itself, the primary concern with many zombies is not running out of memory, but rather running out of process ID numbers.

To remove zombies from a system, the SIGCHLD signal can be sent to the parent manually, using the kill command. If the parent process still refuses to reap the zombie, the next step would be to remove the parent process. When a process loses its parent, init becomes its new parent. Init periodically executes the wait system call to reap any zombies with init as parent.