Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 05-08-2008, 12:17 AM   #1
LQ Newbie
Registered: May 2008
Posts: 1

Rep: Reputation: 0
Will a backgroup job stop after vpn connection fails?


I want to know whether I need to do something special to run a long running script from vpn terminal. Sometime, the vpn session may fail without a good reason. Will the backgroup job stop when the vpn terminal disconnect? If yes, what can I do to run a script which will run event the vpn session disconnect?

Last edited by ernietam; 05-08-2008 at 12:21 AM. Reason: fix typo
Old 05-08-2008, 02:03 AM   #2
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,378

Rep: Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755
Use this cmd format:

nohup yourcmd >yourlog 2>&1 &

& => background
nohup => detaches from terminal, so if cxn breaks, prog will continue.
Old 05-08-2008, 02:15 AM   #3
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Another way of achieving it is running the script on screen, if it is installed (usually is):

screen /path/to/
Then you can press ^A d (or in other words, hold CTRL, press 'a', release CTRL, press 'd') to detach the screen - it will continue running even if you log out, and whenever you want to get it back onto your display, run
screen -d -r
The '-d' switch here isn't necessary unless the screen is already attached somewhere else, so you can leave it off if you know it's detached.

It depends on you then, which one is more comfortable for you.
Old 05-08-2008, 02:33 AM   #4
Senior Member
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (
Posts: 1,900

Rep: Reputation: 69
Yet another way is "disown" command. You use it after the job is launched, which is a benefit. If you have only jobs you want to keep after disconnect, you just say "disown" until it complains about lack of background jobs. The drawback is that you cannot reconnect disowned jobs to your next session.
Old 05-08-2008, 02:39 AM   #5
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Originally Posted by raskin View Post
Yet another way is "disown" command.
First time I heard about that..interesting - thanks for mentioning
Old 05-21-2008, 08:46 AM   #6
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
BTW, disown is an internal bash command -- therefore, which & man won't work on it, but "help disown" will give basic info. about it.

For slightly more info, search the bash man page for "disown [".


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
VPN - is there a way to use VPN & normal connection at the same time? natv Linux - Networking 4 09-05-2007 08:48 AM
Cron job to check/restart network connection? mac_phil Linux - Networking 6 09-01-2004 01:51 PM
httpd service stop fails, no pid, this after latest update squadja Red Hat 2 08-11-2004 02:29 PM
how to stop background job jax8 Linux - Newbie 6 02-17-2004 12:59 AM
squid service fails to stop farhan Linux - Networking 1 03-09-2003 08:12 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:29 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
Open Source Consulting | Domain Registration