NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

mito1's avatar
mito1
Aspirant
Jan 18, 2012

How to keep ssh-session alive?

Hi there,
i often copy a lot of large files from an USB-Share to the NAS or from the NAS to an USB Share. I use a ssh-connection and Midnight Commander because this is much faster than copy the files over ther LAN. But my PC must be "ON" all the time. If I close putty/ssh-session the Midnight Commander - and the copy process - is killed as well.
Is it possible to start the ssh-session or MC on a way that I can shutdown my PC, but the MC will work in the background. And later I start my PC an connect again to it. I hope you understand what I mean :)

7 Replies

Replies have been turned off for this discussion
  • mdgm-ntgr's avatar
    mdgm-ntgr
    NETGEAR Employee Retired
    Schedule MC to run using a cron job. You can place a file in /etc/cron.d containing the schedule you want to schedule it to run.
  • Ohh, I think explained it not clear. I don't need cron-jobs, because these are not periodically copy jobs.
    I'll get an USB-HDD, connect it to my NAS, start Windows, putty, MC and copy the files from the USB-HDD to the NAS. Let's say it will take ~ 4 hours. Now I will shutdown my PC, but MC should be remain working on the NAS ...
  • mdgm-ntgr's avatar
    mdgm-ntgr
    NETGEAR Employee Retired
    Using something like cron you can schedule a command to run in the background. I don't know if this works with mc. You can schedule a job to run and then delete the cron entry once the job is finished.

    I believe you can do some midnight commander stuff as a background job. Not sure how to do this but you can search for info.
  • O.K. thanks for the info.
    I found something about "screen". Maybe this could run on my NAS and help me. I will take a look at that.
  • You can use the at command to run a script in the background.

    eg: $at now <script name>

    This will start the script in the background as a batch job so you can safely log out and the job will continue.

    Cheers,
    Ripface
  • My friend is screen I think 8)

    Installation:
    apt-get install screen

    Login over ssh, starting screen at the prompt
    screen

    Press Enter or space to close Dialog. Then work with the following commands. Every command starts with a [Strg a] and the program waits for a parameter. For example:
    [Strg-a] c


    [Strg-a] [c] - screen - opens a new virtual window
    [Strg-a] [space] - next - changes to next window
    [Strg-a] [d] - detach - set the screen "free", current processes keep on running. You can logout and close ssh-connction now.

    Next ssh-session you type on the prompt
    screen -r
    and the screen is recalled.

    [Strg-a] [K] - kill - Kills the screen session: Really kill this window [y/n]

    HTH
    mito

NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology! 

Join Us!

ProSupport for Business

Comprehensive support plans for maximum network uptime and business peace of mind.

 

Learn More