Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

How to set up a cron job properly?

Options
  • 30-11-2012 5:28pm
    #1
    Registered Users Posts: 1,484 ✭✭✭


    I'm looking to set up a cron job to run a PHP Script on my shared server. I'm having a lot of problems though. I have confirmed that the script functions correctly by navigating to the URL in the browser, so the script isn't the problem. I'm on an Apache server running PHP5.2.17, if that makes any difference.

    My hosting provider provides a Cron Management tool, in there there is the option of cron tabs or scheduled application. I have tried linking to the URL in the scheduled application tab but with no luck. In cron tabs i have used the command:
    lynx > /dev/null -dump "http://mysite.ie/cron.php"
    

    again to no avail. Am i missing something? Do i need to include any extra lines in my script? Is the text before the link to the script correct?

    I'd appreciate any help.


Comments

  • Closed Accounts Posts: 3,981 ✭✭✭[-0-]


    (echo "source $HOME/.cshrc"; echo "lynx -dump http://mysite.ie/cron.php") | csh 1>/dev/null 2>&1
    


    Try something like that.


  • Registered Users Posts: 1,484 ✭✭✭gnolan


    [-0-] wrote: »
    (echo "source $HOME/.cshrc"; echo "lynx -dump http://mysite.ie/cron.php") | csh 1>/dev/null 2>&1
    


    Try something like that.

    I've tried adding a new cron job and using that command but the script is still not performing its function.


  • Moderators, Technology & Internet Moderators Posts: 1,334 Mod ✭✭✭✭croo


    gnolan wrote: »

    I've tried adding a new cron job and using that command but the script is still not performing its function.
    Maybe try curl


  • Registered Users Posts: 1,484 ✭✭✭gnolan


    Could it be a problem in my script?

    I'll give an overview of what the script does.
    1. It first includes an external php file
    2. it also includes jquery.min.js
    3. it calls a JS function on body load
    4. this function queries a webpage, takes the html of the webpage and inserts it into a file on my server
    5. further functions are called which parse this file and insert it into a db on the server

    No data is being added to the server.

    Like I said, if i navigate to the script via a browser it works fine. Is there any difference between how the script is executed through a cronjob?


Advertisement