Arun K
Arun K

Reputation: 121

Run a script on my remote machine from my machine even when the connection is lost

I have a remote machine where i need to run some script say ./main.sh

I am using ssh to login to the remote machine and run the script but when the network connection is lost the script doesn't run.

How can i run a script on my remote machine from my machine even when the connection is lost? Are there any alternatives to ssh in this use case?

Upvotes: 1

Views: 308

Answers (2)

tripleee
tripleee

Reputation: 189607

If the remote system is Unix-compatible, the standard answer is to use nohup.

Upvotes: 1

Zsolt Botykai
Zsolt Botykai

Reputation: 51643

If you have access to cron on that machine, use that (see man cron) for regular runs.

If it's a single case scenario, and you want it to run sometimes after logging in (even if the connection is lost): after logging in, start a screen session and use at.

Upvotes: 0

Related Questions