Category: General

Pages: 1 2 3 >>

02/25/10

Permalink 04:59:01 am, by admin Email , 20 words   English (US)
Categories: General

Hosts File On Mac

Here's a great little article on how to edit the hosts file on a Mac:

http://decoding.wordpress.com/2009/04/06/how-to-edit-the-hosts-file-in-mac-os-x-leopard/

08/24/09

Permalink 06:08:15 am, by admin Email , 46 words   English (US)
Categories: General

SSH session logging

Add the following line to /etc/profile to setup full logging of all ssh sessions:

script -q /var/log/sessions/ssh-`date +%d-%M-%Y-%Hh-%Mm-%Ss`-`whoami`-$$.log && exit

Of course this is a security risk and violates user privacy.

07/14/09

Permalink 06:05:17 am, by admin Email , 42 words   English (US)
Categories: General

Rename file via scripted FTP

Here's an lftp script to rename a remote file vi FTP without downloading the file:

#!/bin/bash

NAS_HOST=myhost
NAS_USER=myuser
NAS_PASS=mypass

SRC=$1
DST=$2

lftp -c "open -e \"mv $SRC $DST\" -u $NAS_USER,$NAS_PASS $NAS_HOST"

03/10/09

Permalink 06:05:23 am, by admin Email , 297 words   English (US)
Categories: General

Content Sync For Load Balancer With Unison

This Unison program is great. It neatly handles syncing between two servers where changes are occurring on both sides. On one client site it takes about 30 seconds to compare/sync a 23GB /var/www/html/ structure with about 100 sites.

1) Install unison (http://www.cis.upenn.edu/~bcpierce/unison/). Requires "ocaml" compiler (http://caml.inria.fr/), and needs the "etags" command from emacs (so "yum install emacs", whatever)

2) Set up a "/root/.unison/profile-name.prf" file. See example pasted below. Comment out "batch=true" and "silent=true" for initial test runs. Uncomment them for running from a cron job.

3) Run manually to test: unison profile-name

4) If you leave the logging turned on, make an /etc/logrotate.d/unison file, something like this:

/var/log/unison.log {
notifempty
daily
rotate 7
missingok
compress
}

5) Set up cron job(s). Create multiple profiles if specific paths need more frequent syncing. With silent=true, the jobs should produce no output (silent=true automatically sets batch=true).

Sample profile (/root/.unison/profile-name.prf)

# Reasonable defaults
auto=true
confirmbigdeletes=true
contactquietly=true
fastcheck=true
group=true
maxthreads=20
numericids=true
owner=true
times=true

# Dump an archive listing to ~/unison.dump
#dumparchives=true

# Skip confirmation
batch=true

# Suppress output (sets batch=true)
silent=true

# Run in a loop, repeating every X seconds (sort of daemon mode)
#repeat=60

# Log all sync operations
log=true
logfile=/var/log/unison.log

# Backup deleted files
backup=Name *
backuplocation=central
backupdir=/var/www/unison-backups


# Local root
root=/var/www/html/

# Remote root (the double forward-slash between IP and remote path is correct)
root=ssh://1.2.3.4//var/www/html/

# Resolve conflicts in favor of local root
prefer=/var/www/html/


# Limit to specific relative path (can specify multiple path= params)
#path=somepath/

# Don't sync (can specify multiple ignore lines)
ignore=Path */var/cache

03/05/09

Permalink 07:17:23 am, by admin Email , 74 words   English (US)
Categories: General

SED Search / Replace Multiple Files

I'm a big fan of the "replace" utility included in the mysql client package. With this utility you can search/replace a string of text across multiple files like this:

replace 'from-string' 'to-string' -- start-folder/*.pl

Quick and easy!

But on occasion I'm on a system that doesn't have the mysql client package so here's a similar function using find and sed:

find start-folder/ -name '*.pl' -exec sed -iorig 's/from-string/to-string/' {} \;

1 2 3 >>

March 2010
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Reliable Penguin offers Linux Server Migrations, Systems Administration & Programming. Visit our main website at:

http://www.reliablepenguin.com

Search

Bookmark and Share

XML Feeds

powered by b2evolution