Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 09-20-2004, 10:57 PM   #1
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.

Old 09-20-2004, 11:08 PM   #2
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.

Old 09-20-2004, 11:20 PM   #3
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.


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 04:05 AM
Shell script to run pl/sql script. colly Linux - General 1 09-09-2004 07:49 AM
how do i run shell script? krt47 Linux - Newbie 4 08-02-2004 10:29 AM
how to run a shell script oasisbhrnw99 Linux - Newbie 1 05-05-2004 02:21 PM
how to run shell script from Kmenu? Howloweener Linux - Newbie 1 05-01-2003 03:12 PM

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

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