linux 后台运行node服务指令
1.后台运行命令 注意:路径要写对,要给绝对路径
/usr/bin/nohup /usr/local/bin/node /var/www/liulin/httpnode.js & >> /home/liulin.txt
添加开机启动服务/脚本
1.开机后执行后台运行操作
在centos7中,/etc/rc.d/rc.local的权限被降低了,所以需要执行如下命令赋予其可执行权限
chmod +x /etc/rc.d/rc.local
这个文件就是开机启动的,然后里面添加
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
#/usr/local/httpdnode.sh
/usr/bin/nohup /usr/local/bin/node /var/www/liulin/httpnode.js & >> /home/liulin.txt
添加最后一条,第一条是默认就有的
网友评论