I have a Linux script on a remote system that I need to execute via a SSH session and it needs to stay running after the session is closed. The script gathers data and stored in a local file for retrieval the next day. Something like:
echo "gathered data" >> daily.log
I can login via putty and execute the script fine using:
I have been able to get the file to start using
After I try to start the script I run another routine to see if it did indeed start by looking at the results of a ps | grep myscript.sh
If I start the script manually I do get correct results from this routine so I know it is working.
Any thoughts on how to start a script remotely and keep it running after the session is closed?
echo "gathered data" >> daily.log
I can login via putty and execute the script fine using:
/sbin/myscript.sh &
ornohup /sbin/myscript.sh &
But I cannot get it to work using ssh.net. My code looks like this:ssh.Connect()
Dim startString = "/sbin/myscript.sh &"
Dim command = ssh.RunCommand(String.Format("{0}", startString))
Dim result = command.Result
ssh.Disconnect()
I've also prefaced the command with sh -c without success.I have been able to get the file to start using
/sbin/myscript.sh >/dev/null 2>&1 &
but as this redirects stdout no data is getting written to my file.After I try to start the script I run another routine to see if it did indeed start by looking at the results of a ps | grep myscript.sh
If I start the script manually I do get correct results from this routine so I know it is working.
Any thoughts on how to start a script remotely and keep it running after the session is closed?