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 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:
    51
    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:
    56
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. lukeit

    lukeit Registered

    Joined:
    Jun 2, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    51
    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,608
    Likes Received:
    32
    Trophy Points:
    238
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. lukeit

    lukeit Registered

    Joined:
    Jun 2, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    51
    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,608
    Likes Received:
    32
    Trophy Points:
    238
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
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