LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Will a backgroup job stop after vpn connection fails? (https://www.linuxquestions.org/questions/linux-newbie-8/will-a-backgroup-job-stop-after-vpn-connection-fails-640693/)

ernietam 05-08-2008 12:17 AM

Will a backgroup job stop after vpn connection fails?
 
Hi:

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?

chrism01 05-08-2008 02:03 AM

Use this cmd format:

nohup yourcmd >yourlog 2>&1 &

& => background
nohup => detaches from terminal, so if cxn breaks, prog will continue.

b0uncer 05-08-2008 02:15 AM

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

Code:

screen /path/to/yourscript.sh
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
Code:

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.

raskin 05-08-2008 02:33 AM

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.

b0uncer 05-08-2008 02:39 AM

Quote:

Originally Posted by raskin (Post 3146548)
Yet another way is "disown" command.

First time I heard about that..interesting - thanks for mentioning :)

archtoad6 05-21-2008 08:46 AM

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 [".


All times are GMT -5. The time now is 09:37 PM.