1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

cron job problem?

Discussion in 'PHP & Perl' started by nexty, Jan 13, 2010.

  1. nexty

    nexty Registered Member

    Joined:
    Oct 18, 2009
    Messages:
    93
    Likes Received:
    10
    Occupation:
    Sys admin
    Hi there,

    I have done a script that allow to grab something from a website and put in on a text file, after that I launch a cleaner (remove duplicate content)

    my script work as I want manually

    but since I dont get a lot of experience in cronjob, I'm using the cPanel cronjob

    so the point:

    I need first to launch the get.php - this php code, will check the url in list.txt and after that write the result in list2.txt

    second cron job after a several minute, will need to run clean.php who need to have acces to list2.txt and remove the duplicate content from list2.txt and writte on this file

    I get sometrouble to runing this, nobody have an idea of what argument I need to put on my cronjob activity?

    thanks
     
  2. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    you have several options i'll show you only two which is working for me in 100%

    1)add path to your script example: /public_html/folder_ONE/myscripts/yourscript.php
    2)curl --silent --compressed curl http://yourdomain.com/yourscript.php
     
  3. radi2k

    radi2k Junior Member

    Joined:
    Nov 29, 2009
    Messages:
    117
    Likes Received:
    34
    Location:
    Germany
    there are several methods to go:
    1. use "wget" or "curl" in a cronjob (as already stated above)
    2. there are websites out there which provide cronjob services (open a url in regular periods)
    3. you can create a linux typical cronjob in /etc/cron.d/<something_here> which will open the php command line binary which will then parse your code. that whould produce no traffic at all ;)

    cpanel cronjobs can be installed as already posted above. i hope this helps :)
     
  4. blackplastic

    blackplastic Newbie

    Joined:
    Jan 18, 2010
    Messages:
    7
    Likes Received:
    0
    Make a shell script..

    Code:
    #!/bin/sh
    for i in `cat /some/path/on/your/server/list.txt`
    do
    curl -o /dev/null -A "Mozilla/4.0 (compatible; Your Desired Agent)" -s "http://localhost.localdomain/scripts/get.php?p=$i" >> /tmp/list2.txt &
    sleep 3
    echo $i done
    done
    cat /tmp/list2.txt | sort -u >> /some/path/on/your/server/list2.txt
    
    To schedule the job for every Tuesday at 04:35 am:
    Code:
    35 4 * * 2 /some/path/on/your/server/getem.sh > /dev/null 2>&1
    
    I've done this once or twice ;)