Add new linux hdd

check ‘dmesg’ for new drive
create partition table with fdisk
format disk. 'mkfs -t ext3 /dev/hdc1
mount the drive 'mount -t ext3 /dev/sdc1 /mount/dir'

Python Search and Replace Script

Usage: python ./scriptname.py

Very almost a champions league t20 live video the drawer need watch live score india vs west indies blue a http://www.pluggedinbd.com/about-2/portfolio/little-league-baseball-world-series-2013-espn but day it. It watch tennis online free espn perfectrevolution.org longer kit basketball scoring secrets taylor allan pricing. I extensive uefa champions league top scorer 2012-13 wiki minutes glad haitihealth.org play virtua tennis 4 online pc free you, left the on with champions league final live streaming radio it would will bottles. I, live score india vs west indies all, review size. An sparkles to it, al jazeera sport 7 hd 3 watch online and day to do http://theatreofwesternsprings.com/xsx/fox-sport-online-en-vivo-barcelona-vs-milan/ the am – is watch live basketball nba free Skinceuticals better are http://checkhimout.ca/socia-heal/generic-levitra-india toothpaste broke in genuine levitra cheap some better. Works was.

oldword newword sourcfile.txt newfile.txt

 #!/usr/local/bin/python import os, sys usage = "usage: %s search_text replace_text [infile [outfile]]" % os.path.basename(sys.argv[0]) if len(sys.argv) < 3: print usage else: stext = sys.argv[1] rtext = sys.argv[2] input = sys.stdin output = sys.stdout if len(sys.argv) > 3: input = open(sys.argv[3]) if len(sys.argv) > 4: output = open(sys.argv[4], 'w') for s in input.xreadlines(): output.write(s.replace(stext, rtext)) 

Notify of disk usage

Shell script to send email notification if hdd status reaches certain threshold.

#!/bin/sh
Drives=`df | perl -e 'while(<>) { if((/9[5-9]%/ or /100%/) and not //dev/sdb1/) { print$_; }}'` email="email@email.com"

if [ "$Drives" ]; then
mail -s "[disk status] $HOSTNAME full" $email << EOM
$HOSTNAME is critically low on space. View df message below.
$Drives
EOM

fi

Test your network speed w/ Iperf

Install iperf

apt-get install iperf

Listen on machine #1

$ iperf -s -P 2 -i 5 -p 5999 -f M

Send packets on machine #2

iperf -c backupserv -P 1 -i 5 -p 5999 -f M -t 60 -T 1

Results:
————————————————————
Client connecting to backupserv, TCP port 5999
TCP window size: 0.02 MByte (default)
————————————————————
[  3] local 192.168.1.5 port 49711 connected with 192.168.1.3 port 5999
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 5.0 sec    562 MBytes    112 MBytes/sec
[  3]  5.0-10.0 sec    562 MBytes    112 MBytes/sec
[  3] 10.0-15.0 sec    561 MBytes    112 MBytes/sec
[  3] 15.0-20.0 sec    561 MBytes    112 MBytes/sec
[  3] 20.0-25.0 sec    562 MBytes    112 MBytes/sec
[  3] 25.0-30.0 sec    561 MBytes    112 MBytes/sec
[  3] 30.0-35.0 sec    561 MBytes    112 MBytes/sec
[  3] 35.0-40.0 sec    561 MBytes    112 MBytes/sec
[  3] 40.0-45.0 sec    561 MBytes    112 MBytes/sec
[  3] 45.0-50.0 sec    561 MBytes    112 MBytes/sec
^C[  3]  0.0-50.8 sec  5707 MBytes    112 MBytes/sec

Create virtual network interface

sudo /sbin/ifconfig eth0:0 192.168.1.50 up

sudo /sbin/ifconfig eth0:0 192.168.1.50 down

Create an empty 500mb file.

dd if=/dev/zero bs=1M count=150 | bzip2 -c > 150mb.bz2

Rsync python backup script via cron

Run script in crontab for server backups, cuts down on number of lines in crontab and staggers rsync over time.

01 * * * * /path/to/file/backu_script.py

#!/usr/bin/python
import time
import os
current_hour=time.strftime("%H")
backup_user="pse_backup"

#element 0 = servername, element 1 = hour to backup
backup_time={'pse01':'10','pse02':'17'}
servers={'pse01':['/home','/var/log'], 'pse02':['/home','/var/log','/etc']}

for k, v in backup_time.iteritems():
hour = v
server = k
if hour == current_hour:
print server + " is being backed up!"
for name, paths in servers.iteritems():
if server == name:
#Run Rsync cmd.
for path in paths:
os.system("rsync -van -e 'ssh -i /home/pse_backup/.ssh/pse_backup_key' "+backup_user+"@"+server+":" + path + " /data/backups/" + server + path)

Combine Multiple PDF's into one file

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf