foreword
After the installation last redis
night, the reminder was invaded as a springboard machine, and I didn’t care about it at the time. There was nothing urgent and important on that machine, so I hung up two node
scheduled tasks, but this morning I found that the scheduled tasks were not triggered. The wget
, curl
, and other commands in the server node
are all invalid. It seems that the server has been cleaned in depth, and even the scheduled tasks are gone.
After reinstalling the system, reinstall it node
and configure the scheduled tasks.
install node
16.17.0
Install the long-term support version here
Download the installation package
Execute the download command to download the compressed package
wget https://cdn.npmmirror.com/binaries/node/v16.17.0/node-v16.17.0-linux-x64.tar.xz
Unzip the compressed package
tar -xvf node-v16.17.0-linux-x64.tar.xz
configure node
node
Move the file under the current directory /usr/local
and rename it tonode
mv node-v16.17.0-linux-x64 /usr/local/node
node
Environment variables configured after adjusting the directory
vim /etc/profile
The configuration file is shown in the figure below
Add the following configuration at the bottom
export PATH=$PATH:/usr/local/node/bin
Execute the refresh command after saving to make the environment variable take effect immediately
source /etc/profile
verify node
After configuring the environment variables, you can view node
the version through the following command
node -v
npm -v
The installation is complete as shown below
Configure scheduled tasks
For configuring scheduled tasks , keywords crontab
cannot be used directly in the configuration , because they are not recognized, and the specified directory and corresponding execution are required .node
node
bin
js
Point to the command to edit the cron job
crontab -e
In order to verify the expression, select the next minute, 14:25
, the actual node
address is /usr/local/node/bin/node
plus js
the address, and the timing command is as follows:
* 27 14 * * /usr/local/node/bin/node /usr/local/node/project/an/app.js
Save verification no problem