I
I
irvdev2017-03-01 12:04:37
JavaScript
irvdev, 2017-03-01 12:04:37

How to make script autorun in ubuntu server?

Hello! Can't get the script to run automatically.
I tried to do it through forerver. I
installed it globally, then I wrote in the terminal
forever start script.js
The script started, but after restarting the server, it does not start automatically ((
Help, what am I doing wrong?(

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ilya Yakimovets, 2017-03-01
@Zebraa

It is worth looking towards pm2.
It has autostart pm2 startup

D
Di ExTreMe, 2017-03-01
@ExTreMeUA

In order for the script to run at boot, you need to write it in the /etc/rc.local file before the exit 0 line.
If you do not have this file, create it and paste the following content into it:

#
!/bin/sh -e
#Здесь вставляем строку с указанием вашего скрипта.
/usr/sbin/script.js
exit 0

the script must be in the /usr/sbin/ directory

Y
Yuri Chudnovsky, 2017-03-01
@Frankenstine

It's best to write your own service (see /etc/init.d/skeleton sample) and set it to autostart (see man update-rc.d).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question