LinuxQuestions.org
Register a domain and help support LQ
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 11-11-2006, 02:14 PM   #1
Paulsuk
Member
 
Registered: Jan 2004
Distribution: LFS
Posts: 91

Rep: Reputation: 15
Logging off while running task


Hi,

Not a real newbie, but this seems like a newbie sort of question!

Is it possible to set a task running, preferably in the background, and then log out while it executes?

I'm thinking of a big file compile, or a download, for example. I tend to access my linux box via SSH and would like to be able to shut down my laptop while the linux box does it's business.

Any suggestions welcome.

Paul
 
Old 11-11-2006, 02:16 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,276

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
nohup <command> &

will do it where <command> is what you want to run.

If you need to go away from an interactive task and come back to it later, look at the screen program.
 
Old 11-11-2006, 02:19 PM   #3
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
Here are a couple of ways to do it.

You can append an & to the end of your command and it will run in the back ground.

The other way is to use the command "screen", you can find out more with man screen.
 
Old 11-11-2006, 08:06 PM   #4
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 57
+1 GNU screen.

Over ssh, you'll find it's the most valuable tool in your collection
 
Old 11-13-2006, 02:56 PM   #5
Paulsuk
Member
 
Registered: Jan 2004
Distribution: LFS
Posts: 91

Original Poster
Rep: Reputation: 15
To begin with, thanks for the help! I'm on the road to my solution....!

It looks like Screen is what I want. I've downloaded it and installed it and looked at the man page and......

Aggghh!
1st Up, I'm using Linux From Scratch.
2nd I have no GUI - just bash.
3rd The point here is coming in over ssh....

So, I've looked at the man page and am lost. Cn anyone explain it to a mere simpleton like me?

What I would like to know is what do I type / keys do I press if I want to kick of (say) a wget download or a package make, disconnect from the screen, close the ssh session, re-connect later and then re-connect to the screen to view progress / results.

Thanks :-)
 
Old 11-14-2006, 08:47 AM   #6
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
In its simplist usage you can:

Quote:
[joed@fs6 ~]$ screen
By entering the command screen, what you've done is started a new shell. At this point you could run your wget or package make. Now that you have lets say wget running, all you need to do to go back to the previous shell is press CTRL-a followed by the the key d. You should notice that you are now back in your 1st shell. If you type:

Quote:
[joed@fs6 ~]$ screen -list
There is a screen on:
21387.pts-3.fs6 (Detached)
1 Socket in /tmp/uscreens/S-joed.

[joed@fs6 ~]$
You'll see the list of screens that you have. Notice that it says (Detached). That means that screen 21387 is there but you are not attached to it. So to get back to it you would:

Quote:
[joed@fs6 ~]$ screen -R 21387
Actually because you only have 1 screen running you could have just typed:


Quote:
[joed@fs6 ~]$ screen -R
to get back to it. If you have multiple screens running then you would need to include the screen number.

It is handy to name your screens as follows:

Quote:
[joed@fs6 ~]$ screen -S wget
[joed@fs6 ~]$
Now when you list your sessions you'll see:

Quote:
[joed@fs6 ~]$ screen -list
There is a screen on:
21418.wget (Detached)
1 Socket in /tmp/uscreens/S-joed.

[joed@fs6 ~]$
So now if you wanted to you could use the session name of "wget" to go back to that session as follows:

Quote:
[joed@fs6 ~]$ screen -R wget
Then when you are done with a screen you can simply type "exit" to close it down and go back to your original shell.

Hope this helps
 
Old 11-14-2006, 03:43 PM   #7
Paulsuk
Member
 
Registered: Jan 2004
Distribution: LFS
Posts: 91

Original Poster
Rep: Reputation: 15
Hey, WOW!

THAT is EXACTLY what I was looking for. Thanks!!

I'm surprised though. Ithought Linux could do it "out of the box" so to speak, but I can install a package

Paul
 
Old 11-14-2006, 04:00 PM   #8
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
Glad to help,

Best Regards,

Fordeck
 
Old 11-15-2006, 03:18 AM   #9
Buckyjunior
Member
 
Registered: Jul 2003
Distribution: Kubuntu Hardy
Posts: 76

Rep: Reputation: 15
I wasn't looking for this but I'm glad I took a few minutes to look at it. This will be a great help in working with a remote server I use.

Thanks fordeck, for you brief but illustrative explanation of 'screen' and running a background task.

Bucky

Quote:
In its simplist usage you can:

Quote:
[joed@fs6 ~]$ screen

By entering the command screen, what you've done is started a new shell.

. . .
 
Old 11-15-2006, 09:21 AM   #10
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
Your welcome Bucky, glad to help.

Fordeck
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Task bar no longer shows task Richard Rahl Linux - Newbie 3 04-12-2010 10:39 AM
Keep task running after logout Xzanron Linux - General 3 12-14-2004 03:44 PM
syslog running but not logging tantric Linux - Security 1 10-15-2003 08:24 AM
running a script automatically when Logging out? hamster Linux - General 2 06-03-2003 09:49 PM
Having trouble running a task in the background 2016 Linux - Newbie 1 01-27-2002 01:51 AM


All times are GMT -5. The time now is 01:12 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration