Purge Data Daily from Mysql ?

Discussion in 'MySQL' started by -jay-, Apr 26, 2007.

  1. #1
    is there any way to purge data daily from mysql ?
    I have a few tables that i would like cleared everyday automatically from mysql.

    any help is greatly appreciated.

    thanks,
    jay
     
    -jay-, Apr 26, 2007 IP
  2. ruby

    ruby Well-Known Member

    Messages:
    1,854
    Likes Received:
    40
    Best Answers:
    1
    Trophy Points:
    125
    #2
    You could create a cron job that ran at the end of each day that purged data form tables either by using DELETE FROM or TRUNCATE TABLE (if you want to purge all data).
     
    ruby, Apr 27, 2007 IP
  3. -jay-

    -jay- Well-Known Member

    Messages:
    2,311
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    160
    #3
    yes i found out how to do it, last night i did the php files but im having a problem getting crons to run them.
     
    -jay-, Apr 27, 2007 IP
  4. ruby

    ruby Well-Known Member

    Messages:
    1,854
    Likes Received:
    40
    Best Answers:
    1
    Trophy Points:
    125
    #4
    Well create a cron job and the command should be something like:

    /usr/bin/php -f /var/www/webspace/script.php > /dev/null 2>&1


    /usr/bin/php -f
    is the path to PHP


    /var/www/webspace/script.php
    is the path to the script



    /dev/null 2>&1
    is the path to send output
     
    ruby, Apr 27, 2007 IP
  5. -jay-

    -jay- Well-Known Member

    Messages:
    2,311
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    160
    #5
    checked in ftp, i dont see var/www
    my directory is like /home/xxxxx/public_html
    or /home/xxxx/www
     
    -jay-, Apr 27, 2007 IP
  6. ruby

    ruby Well-Known Member

    Messages:
    1,854
    Likes Received:
    40
    Best Answers:
    1
    Trophy Points:
    125
    #6
    Yes you will need to know your paths. The example I provided are how my paths look.
     
    ruby, Apr 28, 2007 IP
  7. -jay-

    -jay- Well-Known Member

    Messages:
    2,311
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    160
    #7
    not working, problem is if i try to run the files direct like xxxxx.com/sample.php it does not work, i have to run them like this xxxxx.com/sample
    so when i put the .php extension in the cron path it says file not found.
     
    -jay-, Apr 28, 2007 IP
  8. abdussamad

    abdussamad Active Member

    Messages:
    543
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #8
    Is the php file executable? chmod +x name_of.php
    Does it have the interpreter in the first line? #!/usr/local/bin/php
     
    abdussamad, Apr 29, 2007 IP