LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-31-2021, 04:59 PM   #1
Ethros
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Rep: Reputation: Disabled
not running in the back ground


I have two lots of programs i need to run in the background but when i close the terminal they close down.

Can anyone help with this

First one is as follows

cd nomp
nvm use 5.10
npm install -g nohup
nohup node init.js


second one is as follows

cd explorer
nvm use 12.14.0
npm install -g nohup
nohup npm start
 
Old 03-31-2021, 07:41 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,328
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
Try starting them with a trailing ampersand:

Code:
someprogram &
You still will not be able to close the terminal, but the terminal will return the command prompt and you use if for other functions.
 
Old 03-31-2021, 07:49 PM   #3
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
I’ve always used nohup when starting a job that needed to continue after I logged off. See the man page.
 
Old 03-31-2021, 07:51 PM   #4
Ethros
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
I’ve always used nohup when starting a job that needed to continue after I logged off. See the man page.
I did but when I closed the terminal it's stops
 
Old 03-31-2021, 07:54 PM   #5
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Try using full path to nohup, like
Code:
/usr/bin/nohup myprogram
 
Old 03-31-2021, 07:57 PM   #6
Ethros
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Emerson View Post
Try using full path to nohup, like
Code:
/usr/bin/nohup myprogram

these are the paths i use

nohup npm start &

nohup node init.js &

And when i close the terminal they still close the program

Last edited by Ethros; 03-31-2021 at 07:58 PM.
 
Old 03-31-2021, 08:02 PM   #7
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
I see. You are not listening. Can't fix that.
 
Old 03-31-2021, 08:03 PM   #8
Ethros
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Emerson View Post
I see. You are not listening. Can't fix that.
we all have to learn somewhere and im very new to this. So maybe a little help is all im asking for
 
Old 03-31-2021, 08:08 PM   #9
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Your shell may have nohup as internal command, and that's what you were using. To make sure you are using the real nohup tool you need to use full path.
 
Old 03-31-2021, 08:14 PM   #10
Ethros
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Emerson View Post
Your shell may have nohup as internal command, and that's what you were using. To make sure you are using the real nohup tool you need to use full path.
this is why im new to this,

is it like home/ubuntu/explorer?
 
Old 03-31-2021, 08:19 PM   #11
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
First you locate nohup
Code:
~ $ whereis nohup
nohup: /usr/bin/nohup /usr/share/man/man1p/nohup.1p.bz2 /usr/share/man/man1/nohup.1.bz2
In my computer it is in /usr/bin/, it is likely you have it in the same location. Then execute it using full path as shown in my earlier post. You need to run CLI commands from console or in a terminal window if you have GUI running.
 
Old 03-31-2021, 08:26 PM   #12
Ethros
LQ Newbie
 
Registered: Mar 2021
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Emerson View Post
First you locate nohup
Code:
~ $ whereis nohup
nohup: /usr/bin/nohup /usr/share/man/man1p/nohup.1p.bz2 /usr/share/man/man1/nohup.1.bz2
In my computer it is in /usr/bin/, it is likely you have it in the same location. Then execute it using full path as shown in my earlier post. You need to run CLI commands from console or in a terminal window if you have GUI running.
/usr/bin/nohup /usr/share/man/man1/nohup.1.gz
mine is same can you help me with what the full path would be please

/usr/bin/nohup node init.js &

?
 
Old 03-31-2021, 08:38 PM   #13
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Just that.
The & takes it out of the foreground screen so you can do other things.
The nohup prevents closing the process when you close the screen.
 
Old 03-31-2021, 09:04 PM   #14
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Alternatively, you might also want to try screen. You can detach from a session, close the terminal and reattach later, again.
Example:
Code:
screen -d -m program # start 'program' in detached mode
You can now close the terminal if you want. You can reattach later with:
Code:
screen -d -r # reattach to session that runs 'program'
You can detach from within a session by pressing C-a + d. If you are running more than one screen session you can use
Code:
screen -ls # list PIDs of all current screen sessions
Then you can attach to one of the sessions by
Code:
screen -d -r [PID] # reattach to session that has PID

Last edited by crts; 03-31-2021 at 09:12 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu 12.04 fonts not clear due to back ground colour sanjayagayan Linux - Newbie 1 04-28-2012 04:01 AM
running back ground jobs in bash tcegrid Red Hat 2 01-09-2010 03:45 AM
what is command to display the process which is running in the back ground vinaykori Linux - General 2 02-07-2008 09:35 PM
how do you save back ground for fedora core 7 flux box gundumfx Linux - Desktop 6 09-26-2007 03:09 PM
A place to find good back ground pics for linux? draven66 Linux - Software 4 05-11-2004 05:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration