Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

how to make a cron job

Discussion in 'General Discussion' started by rebelo, Sep 5, 2003.

  1. rebelo

    rebelo Active Member

    Joined:
    Jun 30, 2003
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    the dark side of the moon
    Hi,
    Rookie question:
    Need to delete automaticaly the files in one special folder that are older than 30 days (th
    ese files are. txt extension and cretaed by a cgi script).
    Believe, by what I´ve read, that a cron job would do it.
    How to proceed ?
    Do we need a just a command in the c panel cronjob window ?
    What to write in that command ?

    Any help would be appreciated

    cPanel.net Support Ticket Number:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    506
    Likes Received:
    4
    Trophy Points:
    168
    cront to remov 30 day old files

    you couild use:
    Do some home work. The find . tells it to start from right here so you would actually want something like
    the -type f tells it a filetype

    the -mtime tells it 30 days old.

    So
    would remove ALL files over 30 days old.

    This should give you a great start.

    cPanel.net Support Ticket Number:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. rebelo

    rebelo Active Member

    Joined:
    Jun 30, 2003
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    the dark side of the moon
    Getting the following error by email:

    find: invalid argument `-f' to `-type'

    Any ideas ?

    cPanel.net Support Ticket Number:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    506
    Likes Received:
    4
    Trophy Points:
    168
    I had a typo,

    you do not use -f

    find /home/usrname -type f -mtime 30 -exec rm {} \;

    cPanel.net Support Ticket Number:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. rebelo

    rebelo Active Member

    Joined:
    Jun 30, 2003
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    the dark side of the moon
    Does not worK :-(
    Have changed for 2 days to test but cretaed file still ther after a week.

    find /home/myusername/public_html/mydirectory -type f -mtime 2 -exec rm {} \;

    what could be the problem ?

    cPanel.net Support Ticket Number:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. cortices

    cortices Well-Known Member

    Joined:
    Mar 10, 2003
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    Dallas, TX
    man find is your friend.

    asmithjr pointed you in the right direction. There is just one thing wrong with the command he supplied.

    Use -mtime -30 instead of -mtime 30. When using just "30" it only finds files that were modified exactly 30 days ago. When using "-30" it finds all files modified any time within the last 30 days.

    Also, you might want to use -ctime instead of -mtime as mtime represents the last time the file was modified which may or may not be the same time it was actually created.

    cPanel.net Support Ticket Number:
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice