SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Cron cmd help

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2007
    Location
    London
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Cron cmd help

    Hi all
    Trying to use a cron job to delete any file in a directory after 24hrs, however the one i've come up with doesn't seem to work. it is as follows

    #!/bin/sh
    find /home/roinsonc494/example.com/cache -ctime 24 -exec rm -f {} \;
    My site caches pages and reuse them for a 24 hr period after which the page is created again so the pages that aren't being used are left in the directory and it racks up a good 70MB of html pages in two days so i wanna get rid of them.

    Thanks for your help in advance.

  2. #2
    SitePoint Enthusiast imxuk's Avatar
    Join Date
    Dec 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd do it like this....

    Code:
    find /home/roinsonc494/example.com/cache/ -mtime +1 -exec rm -f {} \;
    mtime being modification time, you could also use atime for access time i guess... Run it in the shell first, check it works....maybe on a different dir.

    Keep in mind you may also have permission problems. So you could schedule it in cron and output to a text file to review what went wrong.

    Cheers,

    Ed

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2007
    Location
    London
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the reply will do


Bookmarks

Posting Permissions

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