Maintenance

From ScriptMan Wiki
Revision as of 16:38, 5 March 2009 by Pratyush (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Using rsync

For backup to secure file transfer, using rysnc is best choice.

Task : Copy file from a local computer to a remote server

Copy file from /www/backup.tar.gz to a remote server called openbsd.nixcraft.in
$ rsync -v -e ssh /www/backup.tar.gz jerry@openbsd.nixcraft.in:~Output:

Password:
sent 19099 bytes  received 36 bytes  1093.43 bytes/sec
total size is 19014  speedup is 0.99

Please note that symbol ~ indicate the users home directory (/home/jerry).

Task : Copy file from a remote server to a local computer

Copy file /home/jerry/webroot.txt from a remote server openbsd.nixcraft.in to a local computer /tmp directory:
$ rsync -v -e ssh jerry@openbsd.nixcraft.in:~/webroot.txt /tmp
Password

Task: Synchronize a local directory with a remote directory

$ rsync -r -a -v -e "ssh -l jerry" --delete openbsd.nixcraft.in:/webroot/ /local/webroot

Task: Synchronize a remote directory with a local directory

$ rsync -r -a -v -e "ssh -l jerry" --delete /local/webroot openbsd.nixcraft.in:/webroot

Task: Synchronize a local directory with a remote rsync server

$ rsync -r -a -v --delete rsync://rsync.nixcraft.in/cvs /home/cvs

Task: Mirror a directory between my "old" and "new" web server/ftp

You can mirror a directory between my "old" (my.old.server.com) and "new" web server with the command (assuming that ssh
 keys are set for password less authentication)
$ rsync -zavrR --delete --links --rsh="ssh -l vivek" my.old.server.com:/home/lighttpd /home/lighttpd
Original Source : CyberCiti

Reducing Mem Usage on LAMP server

By reducing the SPAMD usage

Go on with the following commands as it is

# touch /root/memon
# chmod 0755 /root/memon
# nano /root/memon

copy below code and paste and then save by ctrl+o

EMAIL="root" # EMAIL ID TO WHICH EMAIL SHOULD BE SENT
SUBJECT="Memory Alert" # SUBJECT OF EMAIL SENT
FILE="/root/tmpmu" # TEMP FILE TO WHICH EMAIL DATA IS WRITTEN
TRIGGER=205 # TRIGGER VALUE AT WHICH CMD's SHOULD BE EXECUTED
BURST=1024 # BURST RAM ALLOTTED
GUD=256 # GURANTEED RAM

#---------------------------DONOT CHANGE ANYTHING BELOW THIS -----------------------------
MF="$(grep MemF /proc/meminfo | awk '{print $2}')"
MemFree="$(( ${MF} / 1024 ))"
MT="$(grep MemT /proc/meminfo | awk '{print $2}')"
MemTotal="$(( ${MT} / 1024 ))"
MU="$(( ${MT} - ${MF} ))"
MemUsed="$(( ${MU} /1024 ))"
BRU=0
BRTT="$(( ${BURST} - ${GUD} ))"
if [ $MemUsed -gt $GUD ]; then
BRU="$(( ${MemUsed} - ${GUD} ))"
fi

echo "Hostname: $(hostname)" > $FILE
echo "Local Date & Time : $(date)" >> $FILE
echo "" >> $FILE

echo Memory Usage(Used/Guaranteed RAM): $MemUsed/$GUD >> $FILE
echo Burst Usage: $BRU/$BRTT >> $FILE
echo "" >> $FILE

if [ $MemUsed -gt $TRIGGER ]; then
#--------SET THE BELOW COMMANDS INSIDE THE BRACKETS WHICH YOU WANT TO RUN ON TRIGGER-------
 #echo "$(/etc/rc.d/init.d/exim restart)" >> $FILE
 #echo "$(/etc/rc.d/init.d/mysql restart)" >> $FILE
 #echo "$(abc3)" >> $FILE
 echo "$(/scripts/restartsrv spamd )" >> $FILE

# /bin/mail -s "$SUBJECT" "$EMAIL" < $FILE
fi
echo > $FILE

Now we will move on to setup cron tab.

# crontab -e

Add this line below


* * * * * /bin/sh /root/memon

This will run the script every minute. Its better not to put too much intrevals between runs. The script performs restarts and notification only when it exceeds memory trigger set by you.

reducing the spamd child number

In summary, editing the init script /etc/init.d/exim to change the spamassassin startup options works (if you use the init script to restart exim/spamd), but restarting Exim/Spamd via WHM will restart with the default 5 children.

search for --max-children: and change it to 1 or 2

Personal tools