I want to create a batch file in windows to do specific commands on redhat linux server
When user click on batch file
1- login to server using root user
2- restart some service
3- logout from server
Am able to do cron job to do these commands but I want to restart service manually.

Recommended Answers

All 3 Replies

It looks more like a windows question than a linux question. I think the plink.exe tool can execute remote commands through ssh.

You can also do this with the bash shell and ssh from Cygwin on Windows. I used to use those tools extensively for management of Linux servers as well as software development for Linux on Windows.

  • You can run commands on a remote server using SSH.

Example: To restart httpd service on a server with IP: 192.168.1.10 using SSH, you could do the following:

ssh -t root@192.168.1.10 "service restart httpd"

-You could have the above in a bash script named "restart-remote-service.sh" with the following:

#!/bin/bash
ssh -t root@192.168.1.10 "service restart httpd"

-Make sure the script is executable:

chmod +x restart-remote-service.sh

-For a user to execute, it he could run this script from Mobaxterm/WSL in his machine and it will restart ssh on the remote server.

./restart-remote-service.sh

PS: Just saw this is an old post now. LOL!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.