Find the answer to your Linux question:
Results 1 to 2 of 2
I have several websites that run on a Linux 2.6.9-22.ELsmp system. I am running OsCommerce on them and lately i have files name core.12345 (the numbers of course change with ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2006
    Posts
    1

    Cron job programming help


    I have several websites that run on a Linux 2.6.9-22.ELsmp system. I am running OsCommerce on them and lately i have files name core.12345 (the numbers of course change with the name) that appear to eat up disk space. The webmaster said that the files are caused by bad php programming. I need to have a cron job run daily to delete these files to keep them from eating up the disk space. I have access to the cron command via Cpanel. any help would be greatly appreciated.

  2. #2
    Just Joined! scottro's Avatar
    Join Date
    Feb 2006
    Posts
    57
    The first point to remember with cron is that it has a shorter $PATH than most things, so you often have to specify a command's $PATH. In other words, if, for example, in FreeBSD, I have a script that I run from cron, that has a path of /usr/local/bin/ I have to specify /usr/local/bin/<program> in the script, or cron won't be able to find it.

    As for your script, assuming that these files all start with the word core, and you have no other files with the word core in them, the following should work

    Code:
    find / -name "*core*" | xargs rm -f
    Make it a script and have cron run it whenever you wish. You can make it more specific if you chose, for example, making sure it only finds and removes files named core.[numbers] with something like -name "core\.[1-9]*" (in quotes as I show it.)

    You can test it first by changing xargs rm -f to xargs echo rm -f

    Hopefully, your question is how to find and remove the files rather than how to set up a cronjob.

    If the question is more about how to set up a cronjob rather than how to find and remove the files, you can take a look at this page on getmail for a better explanation about cronjobs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •