Crontab please help

Discussion in 'Site & Server Administration' started by Axcell, Dec 12, 2010.

  1. #1
    I need to run php -q /home/myweb/public_html/check.php every 85 minutes (1 hour 25 minutes) so i added
    */25 */1 * * * php -q /home/myweb/public_html/check.php

    but it run on minute 25 and 50 every hours (based on /var/log/cron).

    please help
     
    Axcell, Dec 12, 2010 IP
  2. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #2
    Set a cron to run every 1 minute: * * * * * /home/myweb/script.sh

    Create a shell script (note set the execute permission on this) script.sh:
    
    #!/bin/bash
    reftime=$(date -u -d "20100515" +%s)
    timenow=$(date -u -d "$(date -u +"%Y%m%d %H:%M")" +%s)
    if [ $(( ($timenow - $reftime) % 5100)) -eq 0 ]
    then
    php -q /home/myweb/public_html/check.php
    fi
    
    Code (markup):
    Or does the script allow you to run it faster e.g. once per hour, would be simpler if it did.
     
    tolra, Dec 12, 2010 IP
  3. vimal7370

    vimal7370 Greenhorn

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    Why cant you just run it as:

    */85 * * * * php -q /home/myweb/public_html/check.php

    This should work fine afaik
     
    vimal7370, Dec 13, 2010 IP
  4. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #4
    If you try and enter */85 via cPanel it reports it as an error
     
    tolra, Dec 13, 2010 IP
  5. vimal7370

    vimal7370 Greenhorn

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    You are right, it accepts only values 0-59 for minutes.. I think you will have to go for the solution you mentioned (via script)
     
    vimal7370, Dec 14, 2010 IP