I believe that many readers (PHP enthusiasts) often complain during the process of work and study: How to make PHP automatically send emails at regular intervals in WIN? ? How to make MYSQL realize automatic backup without worries? ? Of course it can be done entirely manually, but the operation seems a bit too cumbersome! Don't worry, this problem can be easily solved by using the system's task scheduler (called a scheduled task in Windows 98). This feature is often overlooked or never thought of by many users :).
The so-called task plan is to automatically call the application program set by the user in advance by the computer, thereby simplifying the user's operation. Using the task scheduler of Windows 2000 (equivalent to the cron program under *NIX, which will not be described in detail here), we can arrange for any script, program or document to run at the most appropriate time to meet our own needs. The following takes Windows 2000 as an example.
Specifically, if we need to use the task scheduler to run automatically, we should perform the following steps:
1. Click the "Start" button, and then select "Programs" → "Accessories" → "System Tools" → "Task Schedule" (or "Settings" → "Control Panel" → "Task Schedule") to start the Windows 2000 task schedule management program.
2. Double-click the "Add Task Plan" icon in the "Task Plan" window to start the system's "Task Plan Wizard", then click the "Next" button and select the desired program from the given program list. Automatically run the application and click the "Next" button.
Set an appropriate task schedule name and select the time frequency to automatically perform this task (such as daily, weekly, monthly, one-time, every time you start the computer, every time you log in, etc.), then click "Next " button.
At this time, the system will ask the user to set the specific time for the program to run, such as what day, what time, what time period it can run, etc. We only need to set it according to our own needs.
4. Next, the system will ask the user to set an appropriate username and password (as shown in Figure 5) so that the system can run automatically in the future.
5. Finally, we only need to click the "Finish" button to add the corresponding task to the Windows 2000 Task Scheduler. After that, it will automatically "remember" the task once the system time and If the relevant conditions match the plan set by the user, it will automatically call the application specified by the user, which is very convenient (every time you start Windows 2000, the task scheduler will automatically start and run in the background to ensure that the user's plan can be scheduled on time. implement).
Now let’s test whether the task we just created is successful. Right-click the “php” program icon (as shown in Figure 6) and select “Run” in the pop-up menu. Under normal circumstances, the program icon can be started normally as long as it is activated in this way. If the operation fails, you can check whether the user and password are set correctly, and confirm whether the "Task Scheduler" service has been started. I turned it off to save system resources, which caused the operation to fail, which cost me a long time to find. In addition, you can also check the "System Log" to see what caused the operation to fail.
Okay, after talking about so many tasks planning applications, let’s get to the point. Two examples will be introduced below:
1. Let PHP run regularly!
1. Edit the following code and save it as test.php:
<?php $fp = @fopen("test.txt", "a+"); fwrite($fp, date("Y-m-d H:i:s") . " 让PHP定时运行吧!/n"); fclose($fp); ?>
2. Add a task plan and enter the command in this step (as shown in Figure 2): D:/php4 /php.exe -q D:/php4/test.php
3. Set the time to run every 1 minute, and then run the task.
4. Now let’s see if the content of the d:/php4/test.txt file is successful. If the content is as shown below, congratulations on your success.
2003-03-03 11:08:01 Let PHP run regularly!
2003-03-03 11:09:02 Let PHP run regularly!
2003-03-03 11:10:01 Let PHP run regularly!
2003-03-03 11:11:02 Let PHP run regularly!
2. Make it possible for MYSQL to realize automatic backup!
1. Edit the following code and save it as backup.php. If you want to compress it, you can copy a 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]; ?> <option> <option> can be database name you would like to backup. With the --help, or -? options, you can get this help and exit. <?php } else { $dbname = $argv[1]; $dump_tool = "c://mysql//bin//mysqldump"; $rar_tool = "d://php4//rar"; @exec("$dump_tool --opt -u user -ppassword $dbname > ./$dbname.sql"); @exec("$rar_tool a -ag_yyyy_mm_dd_hh_mm $dbname.rar $dbname.sql"); @unlink("$dbname.sql"); echo "Backup complete!"; } ?>
2、添加一个任务计划,在(如图2所示)这一步输入命令:
D:/php4/php.exe -q D:/php4/backup.php databasename
3、时间设置为每天运行一次,然后运行这个任务。
4、最后会在d:/php4/目录下生成一个以数据库名和当前时间组成的rar文件。
5、恭喜你!大功告成了!
当然备份方式有很多种,读者可按照自己喜欢的去做!
以上是原著.结合本人实贱,补充说明如下:
1. 如果出现错误:
在试着设置任务帐户信息时出现错误
指定的错误是:
0x80070005:拒绝访问
您没有运行所请求的操作的权限
在上面'"4.接下来系统将会要求用户设置适当的用户名及密码(如图5所示),以便系统今后能自动加以运行".这里最好用"system"用户,密码可为空.如图:
这个system的权限非常之高,比你的administrator还要高,所以你在运行命令的时候千万不要乱来,这个可是什么提示都没有就会无条件执行的,这个权限下你kill核心进程都行.
2.上面'"'2、添加一个任务计划,在(如图2所示)这一步输入命令:D:/php4/php.exe -q D:/php4/test.php",正确形式应为 '"D:/php4/php.exe'" -q '"D:/php4/test.php'" ,即路径要用双引号括住.
相关推荐:
windows定时执行PHP的技巧 windows10 下载 windows优化大师 windows7 64位旗舰
The above is the detailed content of Windows executes PHP regularly. For more information, please follow other related articles on the PHP Chinese website!

c盘的users是用户文件夹,主要存放用户的各项配置文件。users文件夹是windows系统的重要文件夹,不能随意删除;它保存了很多用户信息,一旦删除会造成数据丢失,严重的话会导致系统无法启动。

启动任务管理器的三个快捷键是:1、“Ctrl+Shift+Esc”,可直接打开任务管理器;2、“Ctrl+Alt+Delete”,会进入“安全选项”的锁定界面,选择“任务管理器”,即可以打开任务管理器;3、“Win+R”,会打开“运行”窗口,输入“taskmgr”命令,点击“确定”即可调出任务管理器。

PIN码是Windows系统为了方便用户本地登录而独立于window账户密码的快捷登录密码,是Windows系统新添加的一套本地密码策略;在用户登陆了Microsoft账户后就可以设置PIN来代替账户密码,不仅提高安全性,而且也可以让很多和账户相关的操作变得更加方便。PIN码只能通过本机登录,无法远程使用,所以不用担心PIN码被盗。

对于刚刚开始使用PHP的用户来说,如果在Windows操作系统中遇到了“php不是内部或外部命令”的问题,可能会感到困惑。这个错误通常是由于系统无法识别PHP的路径导致的。在本文中,我将为您提供一些可能会导致这个问题的原因和解决方法,以帮助您快速解决这个问题。

win10自带的onenote是UWP版本;onenote是一套用于自由形式的信息获取以及多用户协作工具,而UWP版本是“Universal Windows Platform”的简称,表示windows通用应用平台,不是为特定的终端设计的,而是针对使用windows系统的各种平台。

因为win10系统是不自带扫雷游戏的,需要用户自行手动安装。安装步骤:1、点击打开“开始菜单”;2、在打开的菜单中,找到“Microsoft Store”应用商店,并点击进入;3、在应用商店主页的搜索框中,搜索“minesweeper”;4、在搜索结果中,点击选择需要下载的“扫雷”游戏;5、点击“获取”按钮,等待获取完毕后自动完成安装游戏即可。

windows操作系统的特点包括:1、图形界面;直观高效的面向对象的图形用户界面,易学易用。2、多任务;允许用户同时运行多个应用程序,或在一个程序中同时做几件事情。3、即插即用。4、出色的多媒体功能。5、对内存的自动化管理。

在windows中鼠标指针呈四箭头时一般表示选中对象可以上、下、左、右移动。在Windows中鼠标指针首次用不同的指针来表示不同的状态,如系统忙、移动中、拖放中;在Windows中使用的鼠标指针文件还被称为“光标文件”或“动态光标文件”。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
