4

I need to do remote login to a server and run a shell script with arguments in the background using nohup. But I am getting an error. Am I missing anything in syntax?

Mycode:

ssh -t -t user@servername nohup /path/myscript.sh argument1 argument2 & > /path/myscrip_logfile.log

Output:

Invalid null command.
Jill448
  • 1,745
  • 10
  • 37
  • 62
  • Possible duplicate of [How to include nohup inside a bash script?](https://stackoverflow.com/questions/6168781/how-to-include-nohup-inside-a-bash-script) – jww Mar 06 '18 at 22:43

1 Answers1

3

nohup accepts arguments like you have supplied, the "& >" should be "&>" and the whole command should be put in quotes as otherwise i think you are redirecting the stdout of the ssh command so try this:

ssh -t -t user@servername "nohup /path/myscript.sh argument1 argument2 &> /path/myscrip_logfile.log"
terrycain
  • 31
  • 3
  • I changed it as suggested, but getting the same error still. Do we need to give "&" at the end of logfile name? – Jill448 Aug 08 '13 at 14:09
  • There should not be a need but you can try that. Are you sure the script you are running doesn't generate that error? – terrycain Aug 08 '13 at 17:55