kill liferay script

Here’s a bash kill liferay script!

This should kill any running liferay or liferay social office on a linux system.

Open up your favorite editor and paste this in

#!/bin/bash # #Script name: # #Purpose: To kill any running instance of liferay on a linux system # #Usage: ./ # for pid in `ps . . . → Read More: kill liferay script

gzip log files older than one day

To Gzip files older than one day place this in a cronjob: TODAY=`date +”%Y-%m-%d”`

for logfile in /var/log/tomcat6/*.log; do # grab the %Y-%m-%d out of the name DTS=${logfile:(-14):10} if [ $DTS != $TODAY ]; then # compress in place gzip $logfile fi done

kill orphaned httpd processes

to kill orphaned httpd processes create a script called with the following code

#!/bin/bash for pid in `ps -C httpd|sed -e ‘s/^\ \+//g’ | grep httpd|awk ‘{print $1}’` do kill $pid done

howto move mysql freebsd without dump

to move mysql on freebsd without using a dump file follow these steps:

stop mysql copy /var/db/mysql to its new location chown -R mysql:mysql modify /etc/rc.conf and add line mysql_dbdir=”“ modify /usr/local/etc/rc.d/mysql-server and change mysql_dbdir=”/var/db/mysql” to the new location of your mysql directory Start up mysql: /usr/local/etc/rc.d/mysql-server start

rename mysql schema

How can you rename a mysql Schema?


Create the new schema

In this example the new schema is called my_new_schema

mysqladmin -u root -p create my_new_schema Dump the old schema and pipe in to new schema mysqldump -u root -p old_schema | mysql -u root -p my_new_schema

ssh port forwarding example

A ssh port forwarding example would be to map a remote host’s 3306 port to your local machines 3306 port over ssh.

Remote Host: Your Host: localhost

To port forward a mysql connection on a remote host to your local host you would run:

ssh -L 3306:localhost:3306 [email protected]

Once this is mapped you can . . . → Read More: ssh port forwarding example

perl replace text in multiple files

perl replace text in multiple files

perl -pi -e ‘s~OLDTEXT~NEWTEXT~g’ /path/to/filenames/*

Alternative (to avoid escaping slashes):

perl -pi -e ‘s|w/|with|g’

convert ascii mysql db to utf8

how to convert ascii mysql db to utf8 ?

I had a MyISAM mediawiki 1.11.0 database that needed to be utf8 to upgrade to the latest version. Before I could upgrade it I had to convert it to utf8.

Here’s the steps on FreeBSD:

mysqldump -u root -p –default-character-set=latin1 -c –insert-ignore –skip-set-charset -r wikidb_latin1a.sql wikidb . . . → Read More: convert ascii mysql db to utf8

bash diff alternative

How to setup a bash diff alternative nano -w /usr/bin/diff2

Copy and paste the below in to /usr/bin/diff2

#!/bin/bash # # name: # usage: ./ file1 file2 # To make available to whole system copy to /usr/local/bin # and rename to diff2 # colorize diff output for ANSI terminals # based on “diff2html” # . . . → Read More: bash diff alternative

Linux one liners

Linux one liners Diff two directories diff -rq /dir1 /dir2 Set suid

File: File executes as the user that owns the file, not the user that ran the file

chmod u+s Set sgid File: File executes as the group that owns the file Dir: Files newly created in the directory have their group owner set . . . → Read More: Linux one liners