The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to set cron job in cpanel 3 vps optimized

Discussion in 'General Discussion' started by lukeit, Jun 2, 2012.

  1. lukeit

    lukeit Registered

    Joined:
    Jun 2, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    hello,

    in the cpanel at "cron job" i set something like this for to delete the files in video folders every 5 min, but still not works

    0 0 * * * find /home/mysite.tld/public_html/videos -mmin +5 -exec rm {} \;


    i should to delete "-mmin +5" ? (i made already the time in a filed in "Common Settings)


    thankyou
     
  2. GIANT_CRAB

    GIANT_CRAB Well-Known Member

    Joined:
    Mar 23, 2012
    Messages:
    89
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Hello,

    cPanel 3?

    Isn't the latest cPanel version 11?

    Never mind, ontopic:

    min, hour, days, weeks, months.

    so it should be:

    */5 * * * * find /home/user/public_html/videos -f exec rm {} \;

    I am not very sure about the last part so please correct me if I am wrong

    Notes:
    -f means file finding only.

    Hope it was helpful.

    Yours truly,
    GIANT_CRAB
     
  3. lukeit

    lukeit Registered

    Joined:
    Jun 2, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    it tell me "-" is a bad command.
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    This would be the proper way to do it:

    Code:
    */5 * * * * find /home/user/public_html/videos -type f -exec rm -f {} \;
    The -f after "-exec rm" is a force flag and "type -f" tells it to just remove the files rather than directories. I am entirely against using rm in any type of way such as this. It would be better to move the files elsewhere and then remove them at a later date manually.
     
  5. lukeit

    lukeit Registered

    Joined:
    Jun 2, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    mannually? i cannot... i have need of a cron job. why is dangerous?
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    It is always dangerous to force remove files as you could miskey the path and destroy a directory or the system itself. We suggest moving files over removing files whenever possible.
     
Loading...

Share This Page