Skip to content

Hub admin - removing core files #60

Description

@ateucher

With this I can find and delete core dumps. Uses find to find files that match the pattern of core. followed by 1-8 digits, then uses file to list the file attributes, and pipes to grep to look for the string core file to confirm it is a core dump. Then use sed to extract the file name from the file output. Store the list of files in a variable; check the list to make sure it looks ok, then pipe into rm via xargs:

core_files_to_delete=$(
    file `find -type f -regextype posix-extended -regex ".+/core\.[0-9]{1,8}"` | 
    grep "core file" | 
    sed 's/\(.*\/core[.][0-9]\{1,8\}\):.*/\1/'
)

# list the files, do a manual inspection
echo "$core_files_to_delete" | xargs ls -lh

# See the total size in bytes
echo "$core_files_to_delete" | xargs ls -lrt | awk '{ total += $5 }; END { print total }'

# delete them
echo "$core_files_to_delete" | xargs rm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions