Results 1 to 8 of 8

Thread: [RESOLVED] Cron Jobs (Creating Self?)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2008
    Location
    >> ( ҉ )
    Posts
    413

    Resolved [RESOLVED] Cron Jobs (Creating Self?)

    Can i create "Cron Jobs" myself to PHP code or is there any other way to do that, because i have own (homehosted) webserver where i would like to have Cron Job visit at the pages for execute action by visiting at the site?

    Thanks.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Cron Jobs (Creating Self?)

    like I said in the previous post you made (and I don't know why you bothered making a new thread for it), a cron job is something ran by your server itself. it has nothing to do with PHP. it's a way of making any command run on the system any number of times throughout the day, week, or month. and it just so happens that you can call PHP from the command line.

    also like I mentioned in my other post, you're only going to be using cron jobs if you are using a Unix server. if you're actually running your own Unix server, I would hope you were confident enough in using your system to be able to figure out how to do it. if not, you could always google how to set up a cron job.

    if you're not using a Unix server, then you're going to be using scheduled tasks in Windows. you can do a google search on how to create a scheduled task in a Windows environment if you need help.

    in either environment, the command you need to run is:

    windows:
    php C:/path/to/my/file.php

    unix:
    php /path/to/my/file.php

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2008
    Location
    >> ( ҉ )
    Posts
    413

    Re: Cron Jobs (Creating Self?)

    My webhost supports cron job, but seems that the my webhost doesn't support connections to another places with fsockopen (it's enabled btw) if i put random gameserver IP and port it says online at my computer, but at my hosting place it says Offline.

    EDIT: And i tought you meant cPanel and webhosting at some other place (in last thread)
    Last edited by Zeuz; Jan 30th, 2010 at 11:55 AM.

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Cron Jobs (Creating Self?)

    um, what I said in the last thread and this thread above applies to servers in general. a unix server uses cron jobs (which can be changed via cPanel if your host has it installed), and a windows server uses scheduled tasks (which can probably be changed via whatever control panel they would have). if your host won't let you open connections to other servers, though, then that's a whole different issue.

  5. #5
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Re: Cron Jobs (Creating Self?)

    if i get what you want to try then i guess you just want to update some content of your site without updating the whole site, this will be fsockopen. you could try using the same thing as facebook uses for updating their content, they refresh even if you don't refresh your browser...

    Link, thats where i found the code...

    Code:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
    libs/jquery/1.3.0/jquery.min.js"></script>
    <script type="text/javascript">
    var auto_refresh = setInterval(
    function ()
    {
    $('#fsockopen').load('loadcontent.php').fadeIn("slow");
    }, 300000); // 300000 = 5 min (milliseconds)
    </script>
    
    <body>
    <div id="fsockopen">
    <?php 
    $host = "192.168.1.13";
    $port = "80";
    @$socket = fsockopen($host, $port, $errno, $errstr, 5);
     if(!$socket) { 
      echo "Offline";
     } else { 
      fclose($socket); 
      echo "Online";
     } 
    ?>
    </div>
    </body>
    now you create a file called loadcontent.php and in there you put
    Code:
    $host = "192.168.1.13";
    $port = "80";
    @$socket = fsockopen($host, $port, $errno, $errstr, 5);
     if(!$socket) { 
      echo "Offline";
     } else { 
      fclose($socket); 
      echo "Online";
     }

  6. #6
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Cron Jobs (Creating Self?)

    The PHP page you're loading via AJAX is still using fsockopen(), which zeuz said his host won't allow; so it won't work.
    Last edited by SambaNeko; Jan 31st, 2010 at 11:45 AM.

  7. #7
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Cron Jobs (Creating Self?)

    I don't know if this would help?
    Last edited by Nightwalker83; Feb 1st, 2010 at 05:35 AM. Reason: Fixed spelling!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  8. #8
    New Member
    Join Date
    Feb 2010
    Posts
    1

    Re: Cron Jobs (Creating Self?)

    You could use a service like http://www.cronwatch.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width