Solarum – Information For Everyone

Archive for the ‘UNIX’ Category

Feb
22

MySQL Database Backup Script

Here we go folks, I thought I would share a handy little script with you that I use to backup all of the databases on a particular Linux/UNIX server.  I do this by getting a list of the databases, and then using mysqldump to dump them all to a text file.  This seems to be the best way (short of replication) to get good clean backups of the data.  Toss it into a cron job and you can have it done automagically.  There isn’t anything yet to rotate files, but I might add that later.  Also, I am going to try and rewrite this in PERL so our Windows (and other OS’s that don’t have a shell like Bash) brethren can run this script as well.  For now though, it’s written for Bash but almost any shell would work I think.

OK, onto the script.  Read the rest of this entry »

Feb
2

Solarum’s MySQL Reference

Heads up, I have added something that I think you will find useful.  I have added a MySQL reference to the Library!  This is more than a cheat sheet, I try to explain the things that are going on in there as we do it, so it should be a good way to not only see how to do specific things, but also understand them as well.  Check it out here and see what you think, if you see anything wrong with it or you have some tip of you own you’d like me to add, drop a line and let me know.  Enjoy!

Jan
23

Labeling Hard Drives In Linux

Recently I got another external USB hard drive for backing up data. I plugged it in and everything was great except for one thing. The drive came up with the name (label) that Seagate put on there by default. So I was looking a drive mounted at “/media/FreeAgent Drive”, ugh, that sucks. So, I did a little digging and came across this awesome article that covers the many different ways to label your drive. It was interesting that it all basically comes down to your file system, but this article has most everything covered. Check it out

Jan
21

Tired of removing ^M by hand?

Moving files from Windows to UNIX or Linux (and now MacOSX) can be a pain if during the process you end up with a text file full of EOL characters thanks to how Microsoft terminates lines of text in Windows.  Yep, that’s the little ^M at the end of every line.  Sometimes, no matter how hard you try, you can’t help but get stuck with them.

Here’s a tip for getting rid of them once and for all.  Use the dos2unix command!  Just like it sounds, it converts text files riddled with ^M’s to nice pretty *nix happy files.

By default, the command will open and read your file, and write it back to it’s original name and location.  Minus the ^M beasties.  So you can simply do this to convert a file:

dos2unix filename

Yes, it’s that easy.  There are other options if you want to get fancy, read the man page it’s full of information.  Do a quick Google search and you’ll find lots of resources about it, but chances are it’s already part of your Linux distro.  Other operating systems may be different.  Have fun!

Dec
16

PowerUp Your Shell With Your Profile

How about some neat-o shell tricks for everyone to play with? I figured out some neat things the other day while trying to add some functionality to my shell, specifically through scripts or the profile.  What I found was that the magic is in the profile!

Have you ever wanted to have commands that performed certain functions from quick keystrokes rather than long command lines? Of course you have, that’s why we all set aliases in our profiles like ‘ll’ instead of ‘ls -al’ and the like.  But what if you want or need more functionality than simple command shortening? That’s what I was after, more function in a smaller form.  Some way to pass variables to aliases to get more out of them. Ah, but you can’t pass variables to aliases, so we are stuck right? Wrong, that’s where the functions come in to play.

Read the rest of this entry »

Nov
6

Update to the PERL round function

Mr. Thierry H. was kind enough to post a comment with a nice little mod to the PERL round function I posted a while back. With his addition, you can now specify how many digits to show on the right of the decimal. Pretty neat, check it out.

Search

Pages

Articles