Archive

Posts Tagged ‘Linux’

Remove Text from Multiple Files

February 18th, 2010 admin Comments off

Shell script to remove some text from multiple files

Here is a small script that reads all *.txt  or all *.html, all *.php  files and delete all lines between word1 and word2:

#!/bin/bash
FILES="*.php"
for f in $FILES
do
INF="$f"
OUTF="$f.out.tmp"
# replace
sed '/word1/,/word2>/d' $INF > $OUTF
/bin/cp $OUTF $INF
/bin/rm -f $OUTF
done

Then save this file as “myscript.txt”

run this script with: # bash myscript.txt

Categories: Linux Tags: , , , , , , , ,

site redirect code

September 18th, 2009 admin Comments off

To redirect ALL files on your domain use this in your
.htaccess file if you are on a linux web server:

redirectMatch 301 ^(.*)$ http://www.site.net
redirectMatch permanent ^(.*)$ http://www.site.net

You can also use one of these in your .htaccess file:

redirect 301 /index.php http://www.site.net/index.php
redirect permanent /index.php http://www.site.net/index.php
redirectpermanent /index.php http://www.site.net/index.php

If you need to redirect http://site.net to http://www.site.net and you’ve got mod_rewrite enabled on
your server you can put this in your .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site\.net
RewriteRule ^(.*)$ http://www.site.net/$1 [R=permanent,L]

Categories: SEO Tags: , , , , ,

Where did all of the core files come from

September 10th, 2009 admin Comments off

I was recently surprised to see that my wordpress install folders have swelled up in size like anything. I have 3 installs of WP and I noticed that in the root of each install there were dump files with a name pattern “core.*” and with sizes to the tune of 12MB each.

core files come from a core dump. A core dump can happen for lots of reasons, but in shared hosting it generally occurs if:

1. Your site software is not compatible with the latest server software versions.

2. The server software itself was/is having issues.

  • Check the content of the core dump files for clues. It is probably because one of your binaries (i.e. unzip, imagemagick) is not working correctly. If the core files point back to php, then it could be a a memory limit problem, a g2 bug, or a php bug.
  • Try a clean install of WordPress (delete all old files, re-upload, new, empty database). Make sure you backup your blog (export all posts and also back up the database).
  • ( System Administrator ) -  You can stop core files from being produced as a result of suPHP and Rlimit stoppages. In /etc/init.d/httpd at the top of the file you’ll see the ulimit command line. Add a “-c 0″ (slash-c-zero) to the line:
    Code:

    ulimit -c 0 -n x

    where the x above is the number previously assigned by your Rlimit script. That should stop core dump files

Categories: Linux Tags: , , , , ,

Disable yum update

September 10th, 2009 admin Comments off

How disable yum updatesd?
At least one other has seen this and it is a known bug, see: http://bugs.centos.org/view.php?id=2039

  • service yum-updatesd stop
  • chkconfig –levels 2345 yum-updatesd off
  • chkconfig –del yum-updatesd
  • yum –enablerepo=updates-testing install yum-updatesd
Categories: Linux Tags: , , , ,