Jill448
Jill448

Reputation: 1793

Run shell script with arguments using nohup

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.

Upvotes: 4

Views: 17574

Answers (1)

terrycain
terrycain

Reputation: 31

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"

Upvotes: 3

Related Questions