Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hey Guys,
I've come here to ask for some guidance regarding a shell script ( I am very new to this )
I would like to create the following:
A Script that runs on a "logger" box.
This script does the following:
It logs into multiple servers (about 5-6 may have to add more in the future)
and does the following:
It would log into these boxes and change to a certain directory which contain jboss logs; these logs would need to be compressed .tar.gz with a date appending to them so basically .log >> 20120716-log.tar.gz and then the logs would need to be shot across from that server to the "logger" box to a certain directory depending on the server name
so for example
Logger Box does this for SISP1 > the log is made than shot to Logger box under /archives/sisp1/
I would need this to happen for the 4 others (sisp1,2,3,4,5) to the appropriate directory on the logger box.
---
I know I need to set up keys/ known host, but cant really visualize the rest of the script.
could someone give me an example script or something I could look at for location..
All of the actual log files on the remote boxes (sisp1,2,3,4) are all in the same destination on each box.
Please let me know if I could provide any further details.
The basic approach is to set up passwordless login via SSH keys. Then your script should be straight forward. One SSH command to create the tarball, one SCP command to copy it locally. Where are you running into problems?
Ok ,well you should first tell your teacher that using the right tool for the job is, in my opinion, the #1 rule to live by as a system admin.
Since, you have to use a script you can do a cron with ssh/tar as suicidaleggroll suggested. Commandlinefu.com has some examples you can reference, a few are below to help get you in the right direction.
Keep in mind though that we aren't going to write it for you, let us know what you have done, where you are having issues and, if you can, provide some of your code so we can give you some pointers.
ssh user@host "tar -zcf - /path/to/dir" > dir.tar.gz # Would create a tarball remotely
ssh 127.0.0.1 'tar zxvf files.tar.gz -C ~/test/' # would extract a tarball remotely
So where are you having issues at exactly? It looks like it should work without issue, although I havent attempted to run it so I may be overlooking something.
Also, to help us better read your code and prevent any malformation of the code please use the [ CODE] and [ /CODE] tags. Minus the space
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.