Portal Home > Knowledgebase > Articles Database > Keep Command running on power off ??
Keep Command running on power off ??
Posted by VpsHosting, 02-22-2008, 10:03 AM |
Hello
is there any way by which we can keep the command running on PUTTY even when there is Power Failure on our local computer.
What i mean is -
Suppose i am running a TAR command on my BOX and suddenly Power goes off my local PC, so when i relogin i have to start from starch,
is there any way to avoid it, and login back to putty and resume the session ?
|
Posted by apsivam, 02-22-2008, 10:52 AM |
append & at the end of command to make it work in background
for example
for some reason if you want to bring it back foreground use fg command
|
Posted by tracerouteme, 02-22-2008, 12:11 PM |
You can run the command in screen. Use the command screen -S screenname to start a screen and run the command to untar the file in that. The command
screen -ls will list the screen. To quit the screen without interrupting the process running in the screen Ctrl + A + D. To enter the screen again screen -x screenname.
Hope that helps.
|
Posted by VpsHosting, 02-22-2008, 01:01 PM |
This solved my problem, Thank you lotz
|
Posted by VpsHosting, 02-22-2008, 02:04 PM |
Thou, screen works with ALPHA Screen names, but i made a screen with '123' as screen name, thou it opened new screen with '123' as name, but i can not login back to it, by screen -x 123
Can you tell me command to kill this screen 123 ?
|
Posted by sigma, 02-22-2008, 02:13 PM |
It's identified by 18017, not 123, I believe.
Kevin
|
Posted by BigGorilla, 02-22-2008, 02:14 PM |
It's likely trying to look for the PID instead of the name since you used a numerical name. Just do "screen -x 18017" instead (or screen -x if it's the only screen you have created).
|
Posted by VpsHosting, 02-22-2008, 02:16 PM |
screen -x 18017' worked
Thank You
|
Posted by dexxtreme, 02-23-2008, 03:38 AM |
I usually run "screen -r" to resume the screen session that I had going. Of course, that really only works correctly if you only have one screen session at a time. But since I only use 1 screen session and launch multiple shells from inside it (Ctrl + a, c), I almost never have a problem.
|
Posted by john8, 02-24-2008, 09:59 AM |
You can also use "nohup", man nohup for more information.
e.g. if your original command is "tar xzf data.tgz"
You can use "nohup tar xzf data.tgz > tar.log 2>&1 &".
Even if your network connection is lost, the command will finish successfully.
|
Add to Favourites Print this Article
Also Read