将下面的内容保存为sqlreboot.bat,然后添加到计划任务里,就可以实现一段时间后重启sqlserver服务器了,防止sqlserver经常占用内存过高,导致网页无法打开数据。
复制代码 代码如下:
netstopsqlserveragent
netstopmssqlserver
echo.wscript.sleep(50000)>s.vbs
cscript//nologos.vbs
dels.vbs
netstartmssqlserver
netstartsqlserveragent
收缩sqlserver数据库,清空日志文件
复制代码 代码如下:
DUMPTRANSACTION[数据库名]WITHNO_LOG
BACKUPLOG[数据库名]WITHNO_LOG
DBCCSHRINKDATABASE([数据库名])
mysql数据库下实现自动备份并用winrar压缩实现的批处理和php文件
复制代码 代码如下:
FOR/D%%iIN(*)DOD:phpphp5php.exe-qD:phpphp5backup.php%%i
backup.php
复制代码 代码如下:
<?php
if($argc!=2||in_array($argv[1],array('--help','-?'))){
?>
backupVer0.01,forWin95/Win98/WinNT/Win2000/WinXPoni32
Copyright(C)2000ptkerAllrightsreserved.
Thisisfreesoftware,andyouarewelcometomodifyandredistributeit
undertheGPLlicense
PHPShellscriptforthebackupMySQLdatabase.
Usage:<?phpecho$argv[0];?><option>
<option>canbedatabasenameyouwouldliketobackup.
Withthe--help,or-?options,youcangetthishelpandexit.
<?php
}else{
$dbname=$argv[1];
$dump_tool="D:phpmysqlbinmysqldump.exe";
$rar_tool="D:programwinrarrar.exe";
$dateml=date("Ymd");
$yesday=date('Ymd',strtotime('-6day'));
@exec("mdF:sqldatamysqlbak$dateml");
@rmdir("F:sqldatamysqlbak$yesday");
//@exec("$dump_tool--single-transaction--opt-uroot-pxzqcABCD986$dbname>./$dbname.sql");
//@exec("$rar_toola-ag_yyyy_mm_dd_hh_mmF:sqldatamysqlbak{$dateml}$dbname.rar$dbname.sql");
@exec("$rar_toola-ag_yyyy_mm_dd_hh_mmF:sqldatamysqlbak{$dateml}$dbname.rarD:phpmysqldata$dbname");
@rmdir($dbname);
echo"Backupcomplete!";
}
?>