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

Cron question - run script at fixed times throught the day?

Options
  • 15-11-2007 3:24pm
    #1
    Closed Accounts Posts: 12,382 ✭✭✭✭


    Hello

    I have a PHP script I would like to run at 9am 12pm 3pm 6pm and 9pm.

    Is there anyway I can define cron to do this?

    Currently I have it running every three hours, but I would prefer to specify the exact times to run the script.

    Any help appreciated.

    Thanks :)


Comments

  • Registered Users Posts: 3,594 ✭✭✭forbairt


    0 9,12,15,18,21 * * * yourcurrentcommand
    

    would this not do it for you ?


  • Registered Users Posts: 3,401 ✭✭✭randombar


    0 9,12,15,18,21 * * * php http://www.yoursite.com/yourpage.php


  • Registered Users Posts: 3,594 ✭✭✭forbairt


    GaryCocs wrote: »
    0 9,12,15,18,21 * * * php http://www.yoursite.com/yourpage.php

    Ideally this wouldn't be a publically accessible URL as I assume it'll be slightly intensive and you're leaving yourself open to attacks on you system if it becomes common knowledge ... Also ... it won't work as you're trying to load a php file which has already been processed by the server

    As he already had it running every 3 hours I left it as yourcurrentcommand


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    How about something like this:

    Crontab:
    17 16 * * 0 yourShell.sh > yourlog.log 2>&1

    where yourShell.sh contains:

    echo "get /yourPage.php" | telnet yourwebserver 80

    If required, you could try checking that the remote ip address is the one from which the cronjob is running.


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


    I have a cronjob that uses wget to access a password protected page (just basic htaccess protection):
    0 9,12,15,18,21 * * * wget --http-user=TheUser --http-passwd=ThePasswd http://www.yoursite.com/yourpage.php
    
    OP - tell us more about what the script does and the current access method.


  • Advertisement
  • Closed Accounts Posts: 12,382 ✭✭✭✭AARRRGH


    Hello

    Thanks for all the replies.

    I reckon this will do it -

    0 9,12,15,18,21 * * * php -f /home/whatever/yourcurrentcommand.php

    Thanks again everyone! :)


Advertisement