LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-03-2014, 03:30 PM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 671

Rep: Reputation: 46
Wink ssh to a remote machine, execute a command | from Cron


Hey LQ,

I've already managed get a password-less SSH connection going from my home server to my work server for use with rsync back ups.

What I would like to do now is make it so that my home server can also back up the sql database on the work server before the rsync process takes place. I imagine this is fairly simple but I can't seem to figure out how to structure the command.

Thanks in Advance.
 
Old 09-03-2014, 03:55 PM   #2
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
Just connect the way you usually do and add the command you want to run after the user/host bit:

Code:
$ ssh user@hostname 'mysql --backup'
If your command has spaces put it in single quotes. If you need to run several commands you may want to write a quick shell script (on the remote machine) to put them in your desired order, and use that as the command to run.
 
1 members found this post helpful.
Old 09-03-2014, 06:06 PM   #3
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 671

Original Poster
Rep: Reputation: 46
Quote:
Originally Posted by bulliver View Post
Just connect the way you usually do and add the command you want to run after the user/host bit:

Code:
$ ssh user@hostname 'mysql --backup'
If your command has spaces put it in single quotes. If you need to run several commands you may want to write a quick shell script (on the remote machine) to put them in your desired order, and use that as the command to run.
Thank you. That really helped!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] SSH remote command: Pipe remote output to local machine? kenneho Linux - Server 6 12-06-2012 02:37 AM
*Perl* ssh into remote machine and execute parallel copy operation to network drive lunlun Programming 7 08-25-2009 01:08 PM
Need help to execute command on Remote machine tucs_123 Linux - Newbie 4 01-09-2009 03:03 AM
use putty & JavaScript to execute command on remote machine belaviyo Programming 1 10-13-2008 04:45 PM


All times are GMT -5. The time now is 09:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration