LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-10-2005, 06:03 AM   #1
Winter-Storm
LQ Newbie
 
Registered: Aug 2004
Posts: 2

Rep: Reputation: 0
making a process last beyond a session


I don't know how to explain this clearly.

I've got system setup with linux and on it I have got samba, ctorrent, etc...
The system so far works fine and can access the internet and download bittorrents using ctorrent.


I want to start downloads that go overnight. So I login to it over ssh, type in the command to start a ctorrnet download
eg,

$ ctorrent -e 12 torrentName.torrent


It begins the download and everything is fine but when I close the terminal session so does the torrent download (the ctorrent process).


How can I launch the application so that it's life is not linked to the terminal session?
 
Old 11-10-2005, 06:12 AM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
nohup ctorrent -e 12 torrentName.torrent &

The above command will do the trick.. now let me give a short explanation.

The signal all processes receive when the terminal there started in is closed is SIGHUP, or Hang Up. The nohup program's job is to catch that signal and ignore it. Some programs do this on there own, some don't. The & at the end of the command simple means "background" this task. This will startup the task in the background and immediately drop you back to a command prompt. All output from ctorrent will be appended to the nohup.out text file in the current working directory.
 
Old 11-10-2005, 06:12 AM   #3
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
You can try with


Code:
$nohup ctorrent -e 12 torrentName.torrent &
 
Old 11-10-2005, 06:16 AM   #4
mcd2
LQ Newbie
 
Registered: May 2004
Posts: 5

Rep: Reputation: 0
How about running the job using nohup?

nohup ctorrent -e 12 torrentName.torrent &

The displayed output of your ctorrent job should go into a file called "nohup.out". You can direct the results into another filename using standard redirections.

Alternatively, you may also want to run the job under the utility "screen" which will allow you to have a dettachable session - you can check back into a screen session later on to view/interract with the application. This may be desireable over using just nohup which allows no further interraction once you execute it into the background.
 
Old 11-10-2005, 07:20 AM   #5
Winter-Storm
LQ Newbie
 
Registered: Aug 2004
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you everyone that solved it.


mcd2 > I'm looking into the screen utility, just compiling it now
 
Old 11-10-2005, 09:31 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,610
Blog Entries: 4

Rep: Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905
The "background jobs" facilities in bash (that is, your command-prompt) are very useful. Here are a few cool things you can do: (See: info bash.)

(1) When you start any program, bash launches the program and waits for it to complete. If you end the command with '&' then it launches the program and does not wait for it to complete. It is a background job. The command jobs will show you all of the jobs known to the shell. Commands fg and bg let you switch any of them to the foreground.

(2) Pressing Ctrl-Z will stop (suspend) the foreground job, returning you to the shell prompt. You can send the job to the background or resume it in the foreground as you wish.

(3) When you log-off the computer, bash sends a signal to all jobs, unless you used the disown command on them. This signal is SIGHUP. The nohup command causes the program to ignore the signal. Ordinarily the signal causes a program to die.

(4) The nice command allows you to "be nice" to the system and to other users by running a program at lower priority. If a program is resource-intensive, that is "nice" to do. There's also a renice command.

(5) When you log back on to the computer, the jobs command won't list programs that were left behind when you logged off, since this shell does not own them. But the ps command will show that the process still exists (if it still does).

(6) If you want to capture the output of a background job, you should divert the output to a file. For example, I had to rebuild X-windows recently, so I did this: nice nohup make World >WorldLog.txt 2>WorldErrs.txt to say:
  • nice: run this work at reduced priority.
  • nohup: don't die when I log off and go to bed.
  • make World: the command to do the rebuild.
  • >WorldLog.txt: write "normal" output to this file.
  • 2>WorldErrs.txt: write "error" output to this file.
 
Old 11-10-2005, 08:38 PM   #7
Nawar
Member
 
Registered: Nov 2005
Location: Midwest America
Distribution: SuSE, RedHat
Posts: 39

Rep: Reputation: 15
All of the above work...

or

you could just type

at now +1 minute
/fully/qualified/path/to/command with parameters
^D

to submit an at job
then type
exit

to logout.

At will run the process, log the output, and e-mail you the results.
 
  


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
Which process is making DNS queries? TruckStuff Linux - Networking 4 11-29-2005 04:05 PM
xfce4-session fails to save session ! OneManArmy Debian 0 12-10-2004 02:14 PM
Re-attaching a session with process after dis-connection. pymehta Linux - Newbie 0 07-16-2004 09:35 AM
Making process priority "stick"? Phaethar Linux - Software 1 07-15-2004 08:33 AM
What are Session ID, Group ID, Process ID... yrraja Linux - General 4 10-26-2003 10:33 PM

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

All times are GMT -5. The time now is 09:24 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