PHP定时运行

1.编辑如下代码,并保存为test.php:

<?php
 $fp = @fopen("test.txt", "a+");
 fwrite($fp, date("Y-m-d H:i:s") . " 让PHP定时运行吧!n");
 fclose($fp);
 ?>

2.添加一个任务计划,在(如图2所示)这一步输入命令:

D:php4php.exe -q D:php4test.php

3.时间设置为每隔1分钟运行一次,然后运行这个任务。 4.现在我们来看看d:php4test.txt文件的内容时候是否成功。如果内容为如下所示,那么恭喜你成功了。

2011-03-23 17:08:01 让PHP定时运行吧! 2011-03-23 17:09:02 让PHP定时运行吧! 2011-03-23 17:10:01 让PHP定时运行吧! 2011-03-23 17:11:02 让PHP定时运行吧!

二、让MYSQL实现自动备份 1.编辑如下代码,并保存为backup.php,如果要压缩可以拷贝一个rar.exe:

<?php
 if ($argc != 2 || in_array($argv[1], array('--help', '-?'))) {
 ?>

backup Ver 0.01, for Win95/Win98/WinNT/Win2000/WinXP on i32 Copyright (C) 2000 ptker All rights reserved. This is free software,and you are welcome to modify and redistribute it under the GPL license

PHP Shell script for the backup MySQL database.

Usage: <?php echo $argv[0]; ?>

Leave a Reply

(will not be published)