Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6065783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:25:46+00:00 2026-05-23T09:25:46+00:00

My server deployment script triggers a long-running process through SSH, like so: ssh host

  • 0

My server deployment script triggers a long-running process through SSH, like so:

ssh host 'install.sh'

Since my internet connection at home is not the best, I can sometimes be disconnected while the install.sh is running. (This is easily simulated by closing the terminal window.) I would really like for the install.sh script to keep running in those cases, so that I don’t end up with interrupted apt-get processes and similar nuisances.

The reason why install.sh gets killed seems to be that stdout and stderr are closed when the SSH session is yanked, so writing to them fails. (It’s not an issue of SIGHUP, by the way — using nohup makes no difference.) If I put touch ~/1 && echo this fails && touch ~/2 into install.sh, only ~/1 is created.

So running ssh host 'install.sh &> install.out' solves the problem, but then I lose any “live” progress and error output.

So my question is: What’s an easy/idiomatic way to run a process through SSH so that it doesn’t crash if SSH dies, but so that I can still see the output as it runs?


Solutions I have tried:

  • When I run things manually, I use screen for cases like this, but I don’t think it will be of much help here because I need to run install.sh automatically from a shell script. Screen seems to be made for interactive use (it complains “Must be connected to a terminal.”).

  • Using install.sh 2>&1 | tee install.out didn’t help either (silly of me to think it might).

  • You can redirect stdout/stderr into install.out and then tail -f it. The following snippet actually works:

    touch install.out &&  # so tail does not bark (race condition)
    (install.sh < /dev/null &> install.out &
    tail --pid "$!" -F install.out)
    

    But surely there must a less awkward way to do the same thing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:25:46+00:00Added an answer on May 23, 2026 at 9:25 am

    Try using screen:

    screen ./install.sh    
    

    If your ssh session gets interrupted, you can simply reattach to the session via another ssh connection:

    screen -x
    

    You can provide a terminal to your ssh session using the -t switch:

    ssh -t server screen ./install.sh
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to do remote deployment from my build machine onto a server.
I have somewhat interesting development situation. The client and deployment server are inside a
We're looking into setting up a proper deployment process. From what I've read there
I am currently trying to automate the deployment process of our rails app as
I am writing SQL Server deployment scripts which create SQL Server job automatically on
I have a deployment script (.bat), part of which requires calling other programs and
This is VS 2008 and .Net 3.5. I use a custom deployment project script
I've got this script, that uploads some files, connects via ssh and does some
I'm confused, if I select the Create a deployment script option and 'deploy' the
I'm developing application on Django, and ready to move to deployment server. I'm able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.