Thursday, 22 November 2012

How to empty perticular Table in MySQL database Daily with cronjobs

you can create a php script.

truncatetable.php
Example:
<?
$db_host = "localhost";
$db_user = "username";
$db_pass = "password";
$db_name = "databasename";
$connect = @mysql_connect($db_host,$db_user,$db_pass);
@mysql_select_db($db_name);

// Empty table
$query = "TRUNCATE TABLE TableName01";
mysql_query($query);
?>

Then setup the cronjob
Example:
http://www.monetizers.com/cronjob.php

0 0 * * * wget http://www.yourdomain/truncatetable.php


More information about wget http://www.gnu.org/software/wget/manual/wget.html

No comments:

Post a Comment