Categories: TutorialsUbuntu

How to Run Shell Script on Another Server

Shell scripts provide a great way to automate commands, processes and tasks in Linux. Often shell scripts are run on local systems. But sometimes we may need to run a shell script on another server. This is often a requirement for many system administrators that need to do data backups and system maintenance on other systems in their network. In this article, we will learn how to run shell script on another server.

How to Run Shell Script on Another Server

Here is the basic syntax to run shell script on another server.

ssh user@server-name-here /path/to/script
ssh user@server-name-here /path/to/script arg1 arg2 arg3
OR
ssh user@server-name-here /path/to/command
ssh user@server-name-here /path/to/command arg1 arg2
Sponsored

For example, if you have a script /home/ubuntu/data.sh on a remote server 54.43.32.21, then here is the command to run it.

$ ssh test_user@54.43.32.21 /home/ubuntu/data.sh

Please note, you need to have a remote user access to the destination server where you want to run your script. Also you may be asked for an account password before login.

Similarly, you can also run other commands on remote server. Here is an example to run date command on remote server.

Sponsored
$ ssh test_user@54.43.32.21 date

In this article, we have learnt how to run shell script on another server. It is very useful for system administrators to run scripts on other systems to backup data and perform system maintenance. The key is to have execute access on remote system where you intend to run your shell script or command.

Also read:

How to Enable Confirmation for Rm Command
How to Share Linux Terminal Session
How to Use WhoIs Command in Linux
How to Extract & Copy Files from ISO Image
Tools to Scan Viruses & Malware

The post How to Run Shell Script on Another Server appeared first on Fedingo.

Ubuntu Server Admin

Recent Posts

How to Fix VMware’s “Could not open /dev/vmmon” Error on Ubuntu

You’ve recently installed VMware Workstation on your Ubuntu system and encountered the frustrating “Could not…

7 hours ago

How to Fix Ubuntu 404 Errors While Fetching Dependencies

Have you ever found yourself staring at a terminal full of 404 errors while trying…

7 hours ago

How to Fix ‘Please Install All Available Updates’ Error When Upgrading Ubuntu 18.04 to 20.04 LTS

One particularly frustrating error that many users face when trying to upgrade from Ubuntu 18.04 …

7 hours ago

How to fix “Release is not valid yet” Error in Docker Containers

In the world of containerization, time synchronization issues can create unexpected roadblocks when working with…

7 hours ago

How to fix “Externally Managed Environment” Pip Errors on Ubuntu

If you’ve recently upgraded to Ubuntu 23.04 or newer, you might have encountered a frustrating…

7 hours ago

Ubuntu now officially supports NVIDIA Jetson: powering the future of AI at the edge

Canonical announces the General Availability of Ubuntu for the NVIDIA® Jetson Orin™ for edge AI…

14 hours ago