LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-07-2011, 03:34 PM   #1
samanp
LQ Newbie
 
Registered: Dec 2005
Posts: 22

Rep: Reputation: 0
how to gzip log files in remote servers?


Hi,

I have limited access to several servers (key based auth) but cron facility is not available for me. Those servers getting filled up by large apache logs and I have to login to each node manually and clean them each and every day.

I tried to write a script to run from login box but when i try that it looks like it is looking for logs in the local server (login box).

So current situation is;

localbox --> ssh junadmin@server1 "sh /tmp/test/dozip.sh". when executed from login box it says "gzip: a.txt: No such file or directory"

dozip.sh is a one line script in server1's /tmp/test/ which says "gzip a.txt". a.txt is a test file created in server1's /tmp/test dir.

how can i modify this so that the script in server1 will look for files in that server and zip them?

Google showed another command called rsh but in my env it is also not avil.
 
Old 06-07-2011, 03:50 PM   #2
mesiol
Member
 
Registered: Nov 2008
Location: Lower Saxony, Germany
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731

Rep: Reputation: 137Reputation: 137
First you should use full path to excutables in any of your scripts, second do acd to the directory where you whish to do work or specify full pathnames to files
Code:
cd /tmp/test
/usr/bin/gzip a.txt
.

Last edited by mesiol; 06-07-2011 at 03:51 PM.
 
Old 06-07-2011, 04:21 PM   #3
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi there,

As I can understand the scenario you are having a server which generate lot of apache logs and you have to clean them up manually. I will give this server a name say server1.

What you are looking for is to zip these log files on server1 and copy it to server2 and then remove the log files from server1. If that is the case you can go with the following:

1. Use this link to know how to ssh without using password: http://www.linuxproblem.org/art_9.html
2. Create a script say: vi /home/username/remotescript.
3. chmod 777 /home/username/remotescript
4. Once above is configured you can simply add the following commands to the script:

tar -cvf /test/logs.tar /test/logs
scp -rv /test/logs.tar username@xxx.xxx.xxx.xxx:/logs_from_remote/

5. Put this script in crotab
6. If you want to remove the log files one copied to other server then you can create a script for removing logs from original server.

I hope this helps.
 
Old 06-07-2011, 04:56 PM   #4
rn_
Member
 
Registered: Jun 2009
Location: Orlando, FL, USA
Distribution: Suse, Redhat
Posts: 127
Blog Entries: 1

Rep: Reputation: 25
you can simply use: ssh junadmin@server1 "/usr/bin/gzip /tmp/test/a.txt"
 
Old 06-08-2011, 06:20 AM   #5
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
When you say that cron is not available, you mean it’s blocked by the admin for users and crontab -e won’t work? What about running your own background process on these machines which checks every few minutes the size and takes action.
 
Old 06-08-2011, 06:26 AM   #6
digitolx
Member
 
Registered: Nov 2004
Posts: 96

Rep: Reputation: 15
logrotate ?
 
  


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
How to call Shell Script on a remote server with remote servers env variables need Linux - Server 1 10-14-2009 09:37 PM
unable to see files or gzip files in terminal chipstein@aol.com Linux - Newbie 3 10-27-2008 10:46 PM
Doing backup of servers scripts using tar/gzip/scp/rm Swakoo Linux - General 4 12-05-2006 03:09 AM
KDE Remote Desktop Server log files BillyGalbreath Linux - Networking 3 03-12-2006 06:24 PM
I need a a gprs modem to send log files back from a remote location any info paulb2244 Linux - Hardware 1 06-19-2004 03:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:40 AM.

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
Open Source Consulting | Domain Registration