Reputation: 5402
I have a script that will
I would like to scp this script onto a remote computer and execute it using ssh. After it executes the first step of killing all sshd, will it still get to the 2nd step of running sshd again? I'm worried because I'm running the script using ssh and ssh will die after step 1.
Upvotes: 0
Views: 2847
Reputation: 1647
Why not to use cron for it? For example:
10 * * * * /path_to_script
minute hour day month dayofweek command
Do not forget to switch it off;)
Upvotes: 0
Reputation: 123460
Normal procedure is to stop the main sshd, with e.g. /etc/init.d/sshd stop
or your distro's equivalent. This way, the listening daemon shuts down while existing connections go on until the clients disconnect.
If you want to upgrade/replace sshd, change any settings and restart it, this is the way to go.
Upvotes: 2
Reputation: 185053
No need to scp
it to server, just try doing this :
while read cmd; do ssh server "bash -c $cmd"; done < script.sh
Upvotes: 0