I am trying to run a cleanup script that gets invoked on every core dump. I first wrote the contents of the core file to another file, and after then I tried to do a cleanup on the oldest ten files.
xargs rm doesn't work when the script gets invoked via a core_dump. When I run the script by itself, the rm works.
#!/bin/sh cat > "$1" ls -tr /tmp/cores/ | head -10 | xargs rm
If I instead do the below to delete files, it works. But I need to delete only the oldest x files.
#!/bin/sh cat > "$1" rm /tmp/cores
Can someone shed some light?