Archivos CORE Como eliminarlos Como crearlos Solución

¿Qué son los archivos "core"?
Un archivo core es creado por la mayoría de los programas o aplicaciones en tu hosting (moodle, phpbb, coppermine, joomla, etc.) cuando sufren un "crash" (explota). Contienen información destinada a reparar el problema. Normalmente el programa debugger utilizado para leer estos archivos core, es el gdb, que analiza el programa y los motivos del crash.
Los archivos CORE son el producto de un programa que no ha terminado correctamente, los genera el SO con la información para poder realizar un debug (esta el volcado de memoria de cuando ocurrió el problema, estado del programa, y el procesador en el momento que fallan o mueren de forma inesperada).
Estos archivos core se van acumulando y pueden hacerte quedar sin espacio en disco pues suelen ser muy pesado, estamos hablando de decenas de megas.

¿Por qué se generan los archivos CORE?
Cuando un programa realiza una operación ilegal, como dividir por cero, ejecución de una instrucción ilegal o acceso a un área de memoria no permitida, este programa será terminado con una señal del tipo SIGSEGV y se generará un archivo core, es lo que sucede cuando uno ve:
Segmentation fault (core dumped)
Los archivos core generalmente se generan cuando una aplicación intenta usar más memoria que la memoria total del servidor (o la memoria disponible) incluyendo la swap, y esto hace que automáticamente se mate el proceso y deje un fichero core de registro binario. Es posible que la configuración de mysql no sea apropiada (tenga permitido consumir más memoria del total en el equipo) o que alguna aplicación en ese sitio genere un loop, o consuma más memoria que la disponible. Puede revisar el error_log para encontrar información.
¿Como modifico la confguracion mysql?
Los error_log son archivos que se crean por cada error de php que haya en algun sitio, si ubica el que sobrecarga al servidor puede revisar este para ver si le da algun indicio de algun script que demore mucho o consuma mucha memoria.
¿Donde encuentro el error_log?
La configuración de MySQL se encuentra en el archivo /etc/my.cnf, el administrador del hosting debe reiniciar el servicio cada vez que modifique estos datos.
¿Qué contienen los archivos CORE?
Los archivos core contienen una imagen de la memoria del proceso generada en el momento en que dicho programa ejecutó la operación ilegal. Para ver lo que sucedió se puede utilizar GDB (GNU debugger) para analizar cuál fue esa operación ilegal y sus motivos. Es neceario que el programa haya sido compilado con la opción -g para que gdb pueda mostrar información.
gdb programa core. Con esta instrucción gdb cargará el programa con el archivo core el en directorio actual.

¿Cómo hago para eliminar estos archivos CORE que me quitan espacio?
Si no eres programador web y no vas a usarlos, pues en ese caso no te sirven para nada y lo único que hacen es ocupar espacio en tu cuenta, puedes eliminarlos sin problema desde tu ftp. Sin embargo en el caso de programadores, algunos adoran explotar el contenido de los archivos core.
Revisa tu aplicación para que no este fallando y creando estos molestos archivos, si no lo logras puedes pedir ayuda al soporte técnico de tu proveedor de hosting.

¿Cómo hago para generar archivos CORE?
En Linux, están desactivados por defecto. Para poder generar los ficheros CORE introducir : ulimit -c unlimited en bash o limit coredumpsize unlimited. Luego rastrear el problema con gdb.
No olvides eliminar luego los ficheros CORE que no te sirvan pues ocupan mucho espacio. Por ejemplo, para localizar todos los archivos "core" del sistema de archivos /usr a los que no se haya accedido en los últimos siete días y eliminarlos, introduzca: find /usr -name core -atime +7 -exec rm "{}" \;

Copio abajo un artículo que encontré en internet que les será muy util (solo que está en inglés):

Application Core Files in SUSE Linux
Novell Cool Solutions: Feature
By Aaron GreskoRate

When working with support or an application writer to troubleshoot a program, a core file may be requested. A core file is a file created by the operating system when a program terminates unexpectedly, encounters a bug, or violates the operating system's protection mechanisms (See "core" at http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/glossary.html)

By default core files are not created on SUSE Linux systems. Whether or not the operating system creates core files is controlled by the ulimit command. To see the current ulimit setting for core files, do the following:

#ulimit -c
0

The ulimit command sets limits on the resource available to the bash shell. The -c parameter controls the size of core files. The value 0 indicates that core files are not created. To enable core file creation, increase the size limit of core files to a number greater than zero. For example:

#ulimit -c 50000

allows core files and limits the file size to 50000 bytes.

The default value of 0 is set in /etc/profile with the line:

ulimit -Sc 0 #don't create core files

Although the default value for creating core files can be changed in /etc/profile, it's not wise to enable core file creation in most situations. To enable core file creation for a certain user, add the ulimit -c command the the users .profile file.

If you need to enable core file creation temporarily to create a core file for a problem application, increase the ulimit at the command line and then run the application.

Two other parameters allow control of core file creation as follows:

/proc/sys/kernel/core_uses_pid - Appends the coring processes PID to the core file name. The name of the core file is set in /proc/sys/kernel/core_pattern. Default is 0, or don't append the PID. To enable the PID append, use:

echo 1 > /proc/sys/kernel/core_uses_pid


/proc/sys/kernel/core_pattern - Determines the name and location where core files are created. The default on SUSE systems in core, which means that a core file for an application will be created in the processes current working directory and named core. The core_pattern value can include a path. For example, setting core_pattern to /tmp/corefiles/core will cause all core files to be created in /tmp/corefiles and named core. In this situation, using the PID in naming is necessary to avoid overwriting.

The core_pattern can be configured to uniquely name the core file, as described in this excerpt from the proc man page (man 5 proc):

"/proc/sys/kernel/core_pattern
This file (new in Linux 2.5) provides finer control over the form of a core filename than the obsolete
/proc/sys/kernel/core_uses_pid file described below. The name for a core file is controlled by
defining a template in /proc/sys/kernel/core_pattern. The template can contain % specifiers which
are substituted by the following values when a core file is created:

%% A single % character
%p PID of dumped process
%u real UID of dumped process
%g real GID of dumped process
%s number of signal causing dump
%t time of dump (secs since 0:00h, 1 Jan 1970)
%h hostname (same as the 'nodename'
returned by uname(2))
%e executable filename

A single % at the end of the template is dropped from the core filename, as is the combination of a
% followed by any character other than those listed above. All other characters in the template become
a literal part of the core filename. The maximum size of the resulting core filename is 64 bytes.
The default value in this file is "core". For backward compatibility, if /proc/sys/ker­
nel/core_pattern does not include "%p" and /proc/sys/kernel/core_uses_pid is non-zero, then
.PID will be appended to the core filename."


Examples: Creating A Core File

This section will show three different examples of creating core files. All of the examples will use the application top to create core files. The examples will be as follows:

Create a core file in the default pattern with an appended PID
Create a core file in a designated directory
Create a core file using % specifiers

Create a Core File In The Default Pattern With An Appended PID

Complete the following to take a core of the top program in the default pattern with and appended PID (logged in as root):

# ulimit -c unlimited
# echo 1 > /proc/sys/kernel/core_uses_pid
# cat /proc/sys/kernel/core_pattern
core
# top &
[1] 20992
# kill -6 20992

[1]+ Stopped top
# fg %1
top
Aborted (core dumped)
# ls core*
core.20992

Please note that the kill command uses the processes PID and the PID of the process will always be different


Create a Core File In a Designated Directory

Complete the following to take a core of the top program with the core file being saved in a specific directory (logged in as root):

# ulimit -c unlimited
# echo 1 > /proc/sys/kernel/core_uses_pid
# mkdir /corefiles
# chmod 777 /corefiles
# echo /corefiles/core > /proc/sys/kernel/core_pattern
# top &
[1] 20992
# kill -6 20123

[1]+ Stopped top
# fg %1
top
Aborted (core dumped)
# ls /corefiles/core*
core.20123

Please note that the kill command uses the processes PID and the PID of the process will always be different


Create a Core File Using % Specifiers

Complete the following to take a core of the top program using % specifiers (logged in as root):

# ulimit -c unlimited
# echo 1 > /proc/sys/kernel/core_uses_pid
# echo /corefiles/core-%e-%p-%t > /proc/sys/kernel/core_pattern
# top &
[1] 24340
# kill -6 24340

[1]+ Stopped top
# fg %1
top
Aborted (core dumped)
# ls /corefiles/core*
core-top-24340-1129845522

In this example the core file is created in the /corefiles directory. Notice the core filename includes the executable name, PID, and the time of the core. Notice also that the PID wasn't appended to the core filename. The PID is not appended if the %p specifier is used in the filename.

No hay comentarios:

Publicar un comentario

Normas de uso: Los comentarios, quejas y opiniones son de los internautas, no de los creadores de dominioyhost.blogspot.com. Si tienes alguna queja debes identificarte. No está permitido verter comentarios contrarios a las leyes peruanas o injuriantes. Reservado el derecho a eliminar los comentarios que consideremos fuera de tema.