In live system core files are generating frequently. around 10 core files in 30 mins in root file system. which is eating my space very much
below is core file
With a rate of 1 coredumps per 3 minutes I'd rather hurry up to find the malbehaving application, seriously!
In lieu of moving the files after they show up, how about creating them in the right location immediately? Depending on the OS (which you fail to mention) there are various mechanisms to define how the core dump filename will be constucted. man core :
The name of the file is controlled via the sysctl(8) variable kern.corefile (FreeBSD)
... the /proc/sys/kernel/core_pattern file ... can be set to define a template that ... to name core dump files (since Linux 2.6 and 2.4.21)
#!/bin/bash
shopt -s nullglob
cd /root
for cfile in *core*
do
mv "${cfile}" /tmp/scriptor
done
#!/bin/bash
shopt -s nullglob
cd /root
corefiles=( *core* )
if [ ${#corefiles[*]} -ge 1 ]
then
mv *core* /tmp/scriptor
else
echo "No core file" >>core.log
fi
The former moves one file at a time but will miss any files created after the loop starts. The latter will move all the files at once including any created between the two expansions.
cd /root
moved=0
for cfile in core*
do
if [ -f "$cfile" ]
then
mv "$cfile" /tmp/scriptor
moved=1
fi
done
if [ $moved -eq 0 ]
then
echo "No core file"
fi