1

I'm trying to execute a script on a remote server via ssh.

the command should go to the background and continue to run after logout. The result of the command should be redireced to out.log on the remote site.

the ssh process should exit without waiting for the command

The remote shell is csh

I tried various versions (quoting, braces...) of the following line

ssh target.host "nohup csh longrunning.sh > out.log 2>&1 &; exit"

Either my attempts don't do anything on the remote site or I get ambiguous redirect, because of the multiple ampersands.

The remote site is a minimal FreeBSD system, with no tools like screen installed

3

Aren't you just looking for

ssh target.host "nohup csh longrunning.sh >& out.log &; exit"

It seems to be the correct syntax for csh for what you are trying to achieve.

The syntax you are using is incompatible with csh as its syntax is not Bourne shell compatible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.