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!

Cronjob in seconds

Discussion in 'General Discussion' started by SystemJay, Oct 12, 2009.

  1. SystemJay

    SystemJay Registered

    Oct 12, 2009
    Likes Received:
    Trophy Points:
    Hi everyone,
    Im using cPanel (obviously) and I'd like to be able to do a cron job
    that happens every X second. This is for a short time gaming, so
    aswers that you dont need to do it wont work for me =)

    The user interface allows to do a cron job to call a PHP script
    wonderfully, but the minimum time is 1 minute, and Id like to be
    able to call the script every 10 seconds.

    Anyway to achieve this?
    thanks in advance!
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Nov 29, 2006
    Likes Received:
    Trophy Points:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    It is my understanding that CentOS, RHEL and FreeBSD all only support 5 time fields meaning they can only be configured to go as granular as the time interval of minutes.

    Additionally, it is considered poor practice to call a cron job so frequently as it has the potential to add noticeable burden to a shared hosting server. You may wish to consider an alternative method for providing up-to-date information such as a client-side AJAX script interacting with your PHP application.
  3. Spiral

    Spiral BANNED

    Jun 24, 2005
    Likes Received:
    Trophy Points:
    Contrary to what CpanelDavidG said, there is in fact several ways to provide cronjob functionality in seconds though I would not recommend it for most general purposes and that also includes games in particular.

    However, with that said, one of the easiest ways to do this is to call your script every minute (* * * * *) and then loop it 5 times with a 10 second sleep delay between each loop and that will give you every 10 seconds.

    Now going to the other side of the coin so to speak, I agree with CpanelDavidG wholeheartedly in his recommendation for you to drop the cronjob for this and switch over to a Javascript/AJAX interface to push realtime data to client connections as this would be a much better solution.

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