Run shell script with arguments using nohup

Jill448 picture Jill448 · Aug 8, 2013 · Viewed 13.8k times · Source

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.

Answer

terrycain picture terrycain · Aug 8, 2013

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"