I am very new to shell scripting, can anyone help to solve a simple problem: I have written a simple shell script that does: 1. Stops few servers. 2. Kills all the process by user1 3. Starts few servers .
This script runs on the remote host. so I need to ssh to the machine copy my script and then run it. Also Command I have used for killing all the process is:
ps -efww | grep "user1"| grep -v "sshd"| awk '{print $2}' | xargs kill
Problem1: since user1 is used for ssh and running the script.It kills the process that is running the script and never goes to start the server.can anyone help me to modify the above command.
Problem2: how can I automate the process of sshing into the machine and running the script. I have tried expect script but do I need to have a separate script for sshing and performing these tasksor can I do it in one script itself. any help is welcomed.