简体   繁体   中英

How to run my node.js application on when my raspberry pi boots through rc.local?

I am trying to run my node.js application when my raspberry pi boots.

I would like the pi to run the following command on boot:

node bot.js

I first tried adding the following line to rc.local :

node /PPBot/bot.js < /dev/null &

Since that didn't work I tried adding the full path:

node /home/pi/PPBot/bot.js < /dev/null &

This still doesn't work and I currently don't know how to proceed.

Does your bot.js access any files from the current directory? If yes, you should cd to the directory first.

This is what should be in your /etc/rc.local file:

cd /home/pi/PPBot
node bot.js > /dev/null &

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM