8/21/2012

Exclude Directories with find to chown a git project

After running a git pull file permissions tend to get messed up. To fix this I added a hook after merging. I wanted to chown all directories, but exclude a couple. Here's how:

8/09/2012

Compute a good InnoDB log file size

Run these queries during your server’s peak usage time: The log sequence number is the total number of bytes written to the transaction log. Now you can see how many MB have been written to the log in one minute. (This technique works on all versions of MySQL, in 5.0 and newer, you can just watch Innodb_os_log_written from SHOW GLOBAL STATUS, too.) Say we want our logfile to hold at most an hour or so of logs, which is generally plenty of data for InnoDB to work with. For good measure we can round this up to 32MB, and considering the fact that there are two logfiles, divide by half: 16MB per logfile. This seems like a surprisingly small number, but you can monitor this easily enough. Word of advice though: be sure to run the above queries at your server's peak time, or your results might be seriously skewed. Consider running the above multiple times a day over a course of a couple days, and use the average value, so you are on the safe side. That being said, in this particular case, memory being so cheap, I would simply set the log file size to 64MB and be done ;-)

Update: To run this multiple times using a script: https://github.com/datune/innodb_log_file_size

8/04/2012

Compiling GIT on Ubuntu

While configuring the new webserver for the company I work at, I noticed that the git version that can be installed with the package manager is way behind the current git version, so I decided I was going to compile it from source, and while I was at it, create a .deb file so I can easily install it on other servers as well without having to recompile. Let's make sure we have everything installed and all dependencies are met so we can actually compile git. Next download the source code by either downloading directly from http://github.com/git/ or if you have git installed you can also just: Because I already have git installed, and I want to update it, I simply remove it first: Now cd into the git directoy and do the following: This will check all dependencies. Next let's install into /usr and not /usr/local, just like Ubuntu, and we want to have everything, incl. documentation, so we add all to the command, like so: This will take a while, but once it is finished, I COULD simply install it like so: but, that's not what I want. Instead, I want to create a .deb package. First let's create a description file for our package: Add the following in the file: Now we're ready to create the .deb file The -D tells it to create a .deb package, --install=no means we do not want to install it right away. (Btw. if you do not have checkinstall, simply run sudo apt-get checkinstall). When asked to create a documentation directory, simply enter y. Next change the maintainer to your email, and make sure to change the Name (2) to git-core! Add the version like so 1:1.7.12:04.08.12, where 04.08.12 is the current date. Having done all that, just hit ENTER and watch it build our deb package. After that, all that's left is to actually install our package: Btw. here's a useful link which also explains how to install git on Ubuntu: http://evgeny-goldin.com/blog/3-ways-install-git-linux-ubuntu/

7/28/2012

Get system vitals and highest utilizing process

At times it may be handy to periodically store a snapshot of the server's system vitals.

2/09/2012

Restore file permissions

I didn't test it but it must work for owners and owner groups too. Something like:

2/07/2012

Find a directory by name in linux

-type d == directory
-name '.svn' == all directories named .svn
-ls == converts unusual characters to C style escape sequences

To delete the list of directories returned by the above command execute xargs builds and executes command lines from standard input
/bin/rm -dr == remove command with the directory and recursive flags

2/01/2012

Group Sticky bit

To ensure that the group owner of existing and new files stays the same set the group sticky bit like so: