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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

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

  • 15-11-2007 2: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, Registered Users 2 Posts: 3,594 ✭✭✭forbairt


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

    would this not do it for you ?


  • Registered Users, Registered Users 2 Posts: 3,428 ✭✭✭randombar


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


  • Registered Users, Registered Users 2 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, Registered Users 2 Posts: 21,263 ✭✭✭✭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, Registered Users 2 Posts: 6,571 ✭✭✭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