php:在WINDOWS中设置计划任务执行PHP文件
在网上找了些WINDOWS执行PHP的计划任务的方法,有一个写得很全,可惜在我这竟然没通过。最后不得不综合各门派的方法,才能在我这运行成功。
1、写一个PHP程序,命名为test.php,内容如下所示:
[php]
$fp = fopen("test.txt", "a+");
fwrite($fp, date("Y-m-d H:i:s") . " 成功成功了!\n");
fclose($fp);
?>
$fp = fopen("test.txt", "a+");
fwrite($fp, date("Y-m-d H:i:s") . " 成功成功了!\n");
fclose($fp);
?>程序大胆地写,什么include\require尽管用,都没问题。
2、新建Bat文件:命名为test.bat,内容如下所示:
D:\php\php.exe -q D:\website\test.php //相应目录自己改上
3、建立WINDOWS计划任务:
开始C>控制面板C>任务计划C>添加任务计划
浏览文件夹选择上面的bat文件
设置时间和密码(登陆WINDOWS的)
保存即可了。
4、over! 可以右键计划任务点“运行”试试
运行过程省略…………
以上方法有个小问题,计划任务运行的时候,windows桌面会出现dos窗口,在此做些修改。采用vbs的方式实现即可,就不会出现黑色的dos窗口了。代码如下:
DIM objShell
set objShell=wscript.createObject("wscript.shell")
Ireturn=objShell.Run("C:\php\php.exe d:\www\timer.php",0,TRUE)
保存为.vbs文件,替换原来的.bat文件即可。

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics



JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.

How to implement Windows-like in front-end development...

Solving the problem of slow Photoshop startup requires a multi-pronged approach, including: upgrading hardware (memory, solid-state drive, CPU); uninstalling outdated or incompatible plug-ins; cleaning up system garbage and excessive background programs regularly; closing irrelevant programs with caution; avoiding opening a large number of files during startup.

In PHP, the final keyword is used to prevent classes from being inherited and methods being overwritten. 1) When marking the class as final, the class cannot be inherited. 2) When marking the method as final, the method cannot be rewritten by the subclass. Using final keywords ensures the stability and security of your code.

How to distinguish between closing tabs and closing entire browser using JavaScript on your browser? During the daily use of the browser, users may...

The... (splat) operator in PHP is used to unpack function parameters and arrays, improving code simplicity and efficiency. 1) Function parameter unpacking: Pass the array element as a parameter to the function. 2) Array unpacking: Unpack an array into another array or as a function parameter.
