Cron - Execute a file on another domain/server?

Discussion in 'Programming' started by tarponkeith, Jul 11, 2007.

  1. #1
    Ok,
    I would like to run a cron job from CPanel on one server that executes a file on another (either .asp or .php) to update a database...

    I'm used to MS hosts, so "Cron" is new to me, any ideas how I can make:
    host1.com/
    have a cron job to run:
    host2.com/cron.asp

    Thanks...
     
    tarponkeith, Jul 11, 2007 IP
  2. personalpa

    personalpa Peon

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Not sure about how to do that.

    However, you can try making a file, upload to host1.com and execute host2.com file using that.
     
    personalpa, Jul 11, 2007 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    The file on server 2 must be public and should be password protected.

    Peace,
     
    Barti1987, Jul 11, 2007 IP
  4. pruad

    pruad Peon

    Messages:
    71
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can run php (perl/asp..) script on host1.com which get script on host2.com.

    For example:

    on host1.com (do with cron):

    <?php

    file_get_contents ('http://host2.com/make_db.php');
    // also you can use CURL here to get more
    // also do logging here to know if success

    ?>

    on host2.com/make_db.php :

    <?php

    //do your task here

    ?>

    in addition you can improve this idea using password protection of host2.com/make_db.php

    Good luck!
     
    pruad, Jul 12, 2007 IP
    tarponkeith likes this.
  5. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Alternatively, you could always just use wget: it's a command line URL 'grabber', so you could just have cron execute something like:
    wget http://site2.com/somepage.php
     
    TwistMyArm, Jul 12, 2007 IP
    tarponkeith likes this.
  6. tarponkeith

    tarponkeith Well-Known Member

    Messages:
    4,758
    Likes Received:
    279
    Best Answers:
    0
    Trophy Points:
    180
    #6
    Awesome, thanks for the help guys...
     
    tarponkeith, Jul 12, 2007 IP