nohup <command> <arg> &
When I SSH into a Linux server, if I want to run a command and make sure that it will continue to run in the background after I logout from SSH, I will use the above commands.
Recently I am using a server stack called Bitnami Node.js stack. It is a self-contained software bundle. There is a node
binary in the bin folder in the installation directory.
In the command line, I am able to use the node
command to run my JS programs: node <js_program.js>
. There is no problem.
But, I would like to continue to run the program after I logout from SSH. When I run nohup <installation_dir>/nodejs/bin/node <js_program.js> > <stdout.out> &
, the program will run in the background. But, when I logout from SSH, the program will also terminate immediately. It seems that the nohup
command has no effect in this case.
How can I fix this issue?
Running:
will leave stderr and stdin open. Instead, run:
or:
which will redirect stdout and close stdin.
Keep in mind that your command may abort if it can't read from stdin.
If you have the
at
package installed, and you're not denied (either directly via/etc/at.deny
, or implicitly via/etc/at.allow
) from using it, try using either of:or:
and specify your command at the
at>
prompt.This should schedule the command to run immediately via the
at
daemon.This how I've traditionally "emulated"
nohup
on systems with brokennohup
implementations (AIX 5.3 and earlier, for example).I managed to solve this problem by changing the way I logout from the SSH shell terminal.
Instead of clicking the
X
button to close the PuTTY window, I typeexit
in the SSH shell terminal to logout. Now the process is able to continue to run in the background after I logout.If I click the
X
button to close the window, the background process will terminate immediately.