Home  >  Article  >  Backend Development  >  Can PHP scheduled tasks call js libraries?

Can PHP scheduled tasks call js libraries?

(*-*)浩
(*-*)浩Original
2019-10-16 14:14:162909browse

Can PHP scheduled tasks call js libraries?

Node.js implementation

1. Install node.js and related configuration environment

Download address: http:/ /nodejs.cn/ (Recommended learning: PHP video tutorial)

npm will be installed together when installing Node.js. The role of npm is to manage the packages that Node.js depends on, that is, It can be understood as what needs to be installed to install/uninstall Node.js

Can PHP scheduled tasks call js libraries?

Use npm.cmd to install the required modules: mqsql node-schedule jquery express

Can PHP scheduled tasks call js libraries?

Copy the installed environment package and modules into the root directory of the php project

Can PHP scheduled tasks call js libraries?

2. Write php Task file auto.php: Link to the database to determine conditional operation database. This file can be placed in the above nodejs folder

3. Create js file auto.js: This file can also be placed in the above nodejs folder. nodejs folder

node.js creates a scheduled task and executes the cmd command. cmd actually executes the php file: php.exe path php file path

Timing time setting

Execution at a determined time

For example: July 13, 2016 15:50:00, when using new Date(), the month is Minus 1.

var date = new Date(2016,6,13,15,50,0);  
schedule.scheduleJob(date, function(){  
  httpGet();  
});

Run result:

Can PHP scheduled tasks call js libraries?

Create the bat file and put it in the nodejs folder. Content:

Can PHP scheduled tasks call js libraries?

Manually click to execute auto.js and then execute the auto.php file regularly to complete automatic scheduled tasks

The above is the detailed content of Can PHP scheduled tasks call js libraries?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn