Home > Article > Backend Development > 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
Use npm.cmd to install the required modules: mqsql node-schedule jquery express
Copy the installed environment package and modules into the root directory of the php project
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:
Create the bat file and put it in the nodejs folder. Content:
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!