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

wget in cronjob, home dir or web addy?

Options
  • 28-03-2007 1:29pm
    #1
    Registered Users Posts: 307 ✭✭


    am using a cronjob to run a php script to grab currencies from XE and ouanda to update my eshop currency rates.

    all is working ok after my hoster told me I needed to use wget.

    (nb: me no experiencio wit cron or wget)

    the worked example they gave was
    **/2*** /usr/bin/ http://www.your_site.com/your_script.php

    this is working ok, but as it has been recommended to me that the script should not be in a publiclly accessible dir, is it possible to use wget to run a script if it is not located in the /www/ folder?
    (I did try not using wget for this scenario but it didnt work and hosters spec that it must be used)

    also, is someone able to explain to me exactly were the "/usr/bin/" part comes from?


Comments

  • Closed Accounts Posts: 63 ✭✭Greggy


    /usr/bin could basically be translated to "user/binaries", user accessible binaries.

    I would advise looking up cron here:
    http://www.webmasters-central.com/t/cron.shtml

    Im not sure why you would use wget, call the script on the PHP binary. you can call a script anywhere, doesnt have to be web accessible.

    Call script like so in crontab:
    00 15 * * * * /usr/bin/php /path/to/your/php/script >/dev/null 2>&1
    
    The above cron would be called everyday at 3pm. Your path to PHP maybe different, so first find its location.

    This can be done by issuing the following command:
    whereis php
    

    Hope that helps.

    G


  • Registered Users Posts: 568 ✭✭✭phil


    Greggy,

    There are a number of reasons why you may not be able to do that, but first find out if there is a binary version of PHP installed. whereis php will do that (but bearing in mind it may not actually be there).

    Secondly, the script may need to run as the webserver user as opposed to his own user, in which case he needs to use wget.

    Btw, you didn't copy and paste those commands exactly, you seem to have typed them incorrectly. Copy and paste commands exactly, don't type so that we can understand what you're trying to do.

    It depends on what exactly the script is doing, it may be possible to run this directly with a PHP binary as Greggy suggested outside of the www directory, but it's always possible that you can restrict the script to an IP address and even make it require a username & password.

    Again, it depends on your scenario.

    Phil.


  • Registered Users Posts: 307 ✭✭wolf99


    thanks for that folks.

    quick one.
    >/dev/null 2>&1
    
    is for stopping job reports, correct?

    it hasn't seemed to work. I appended it to my command, which was running normally, but the reports are still piling up in my /home/ dir.

    have I used it wrong?


  • Registered Users Posts: 6,511 ✭✭✭daymobrew


    wolf99 wrote:
    I appended it to my command, which was running normally, but the reports are still piling up in my /home/ dir.
    What do the reports say? Do they have errors in them?

    Maybe you could post your code and a copy of one of those reports.


Advertisement