Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    1

    Default Cronjob in seconds

    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. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    10,718
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by SystemJay View Post
    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!
    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. #3
    BANNED
    Join Date
    Jun 2005
    Location
    Wild Wild West
    Posts
    2,025

    Default

    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.

Similar Threads & Tags
Similar threads

  1. Servers blocking for 3-4 seconds
    By filth80 in forum cPGS Discussions
    Replies: 0
    Last Post: 03-17-2011, 09:43 AM
  2. MySQL restarts every few seconds
    By 1EightT in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 01-28-2007, 04:18 PM
  3. how to run a cronjob every 5 seconds?
    By nat in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 07-01-2003, 02:08 PM
  4. FTP Hangs for 10 seconds then goes
    By zartanch in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 04-14-2003, 09:42 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube