LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-20-2004, 09:57 PM   #1
bjdea1
Member
 
Registered: Oct 2003
Posts: 37

Rep: Reputation: 15
How to run script that doesn't terminate when shell closes?


The title says it all. The problem I have is my internet connection disconnects after 4 hours of being online. When I open a shell (ssh) to my server and perform a virus scan or sometimes backups from command line, because our server is a large Dual 2.8Ghz with 3 drives and many users there is a heap of work to do each time these commands execute. It always takes longer than 4 hours - mainly because some of the accounts on the server have enormous file structures. Just listing these directories can take over an hour! So anyway how do I execute a command from shell that will not then die when the shell terminates, but instead keep running until it finishes.

Thanks
 
Old 09-20-2004, 10:08 PM   #2
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Rep: Reputation: 46
Usually running the command with an ampersand:
&
appended will do it.

ls -al &
for example.

For more intricate work, the application "screen" may be of more use
Screen is mentioned in many posts of this type, and also has a very useful (if complicated) manpage. The server may or may not have that application installed. If you don't have root access, contact someone who does to install it for you, or try installing it within your home/bin.

--Shade
 
Old 09-20-2004, 10:20 PM   #3
jspenguin
Member
 
Registered: Feb 2003
Location: Wichita, KS
Distribution: Heavily modified Redhat
Posts: 194

Rep: Reputation: 30
Also, try the nohup command

nohup long_command &

It will redirect the output to nohup.out.

Without the nohup command, ssh will not terminate your session until the job is finished.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run SHELL script pito Linux - Newbie 4 12-17-2004 03:05 AM
Shell script to run pl/sql script. colly Linux - General 1 09-09-2004 06:49 AM
how do i run shell script? krt47 Linux - Newbie 4 08-02-2004 09:29 AM
how to run a shell script oasisbhrnw99 Linux - Newbie 1 05-05-2004 01:21 PM
how to run shell script from Kmenu? Howloweener Linux - Newbie 1 05-01-2003 02:12 PM


All times are GMT -5. The time now is 11:36 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration