1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP + CURL help

Discussion in 'PHP' started by tamilsoft, Jan 4, 2009.

  1. #1
    Hi,

    I have a php file, which uses CURL to post data to some page. Now I want to run this php file from command line .ie., from cron job. Is it possible?
     
    tamilsoft, Jan 4, 2009 IP
  2. cont911

    cont911 Peon

    Messages:
    50
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    1) find where php executable is located
    2) ensure you have access to it from cronjob (depends on your hoster)
    3) run php script as something line this: /usr/bin/php yourscript.php
     
    cont911, Jan 4, 2009 IP
  3. tamilsoft

    tamilsoft Banned

    Messages:
    1,155
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I know buddy hot to run the cron. But I'm not able to run the CURL used php page through cron. It give's the following error:

    Undefined function 'curl_init()'
     
    tamilsoft, Jan 4, 2009 IP
  4. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #4
    There are 3 different versions of php.
    php as a apache module
    php-cli
    php-cgi.

    The one you want is php-cli (command line interface), which probably isn't compiled with curl support in your case.
    A way around is to use wget.
    * * * * * wget -bq -o /dev/null http://www.yoursite.com/script.php >/dev/null 2>&1
     
    Kaizoku, Jan 4, 2009 IP
    tamilsoft likes this.
  5. tamilsoft

    tamilsoft Banned

    Messages:
    1,155
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you mate!, Finally wget has helped me.
     
    tamilsoft, Jan 5, 2009 IP