F
F
Flemy2021-10-12 16:01:50
linux
Flemy, 2021-10-12 16:01:50

Running js script in background via nohup command?

I'm trying to run a js script in the background on ubuntu 20. I'm trying through the nohup script.js & command. I get the following output
Line 1) [1] process number
Line 2) nohup: ignoring input and appending output to 'nohup.out'
Line 3) nohup: failed to run command 'script.js': No such file or directory

If via ps aux to see the processes, Nohup hangs at the end, but it does not work and the script does not work in the background. Any command in the console disables the process. How to run the script correctly, maybe I'm somehow defining the command incorrectly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2021-10-12
@ky0

failed to run command 'script.js': No such file or directory

Try to translate.

S
Saboteur, 2021-10-12
@saboteur_kiev

because this js script is not an executable file. It needs to be launched with something, for example, nodejs,
like python is launched
by python myscript.py
and js, you need
node myscript.js
or nohup node myscript.js &
well, or write the path to the node through the shebang and make the file executable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question