Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, August 3, 2015

How to run a cronjob on the last day of the month

You may have to escape the % sign for direct crontab entry depending on your cron software.  The example runs on the first minute of the last day of the month and starts trying for last day on the 28th (to deal with Feb).

0 0 28,29,30,31 * * [ $(date +\%d -d tomorrow) = “01” ] && command_you_want_to_run

Friday, August 22, 2014

mysqldump warning skipping mysql.event table data

If you don't want to give your "backup" user Super permissions and you don't use events you'll be stuck with an annoying warning:

-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.

Every time you run a scheduled backup of your mysql database.  You still want those cronjob emails with any database backup errors but you don't want that one.  This might help you:

mysqldump --routines -u$USER -p$PASS -h$HOST -r$DIR/$FILE $DB 2>&1 | grep -v 'Skipping the data of table mysql.event' 1>&2

What it does is redirects all errors from mysqldump to STDIN.  It then greps out the event error and redirects any other errors back to STDERR.

The key is that you MUST use the -r option  (write to a file directly to a file rather than STDOUT) with mysqldump.  If you have other warnings you don't want to see you can use:

... | grep -vE '(warning 1 substring|warning 2 substring)' 1>&2

Another option might be to use Cronic.  Good luck!

Wednesday, October 10, 2012

Logging STDOUT, STDERR and outputting STDERR

You may find yourself with the need to log both STDOUT and STDERR but also display STDERR. A perfect example is when running cronjobs on Linux. As we all know getting too many notifications will result in the important notifications being lost in the noise. The solution is generally only to show errors. The problem is that those errors might lose context without various debug information. This is where I/O redirection becomes handy. Because we only want to receive emails (cron automatically sends all STD output as an email to the job owner) for errors we can use the following:

<command> 2>&1 >>blah.log | tee -a blah.log

What this does is runs <command> and copies STDERR (file descriptor 2) to STDOUT (file descriptor  1, 2>&1) and then redirects (>>) STDOUT (file descriptor 1) to blah.log.  Because of the order STDERR is not being appended to the blah.log.   That happens in the pipe to the tee command.  The tee command takes input from STDIN, adds it to a file and then echos that output to STDOUT.  The net result is that we now have STDERR from <command> being emailed to us should we use that series of commands in a cronjob.

Wednesday, January 25, 2012

Six hours spent trying to install Linux Mint 12.

I've been using Linux on the desktop for about 18 years now and needless to say I know my way around pretty well. I've been using Ubuntu 10.04 LTS for the last year or so and recently upgraded to two new drives on my work system. Rather than reinstalling 10.04 LTS I decided to give Linux Mint 12 a try. The catch is that I wanted to do software RAID 1 for the boot partition and RAID 0 for the system. Ubuntu allows software RAID configuration using its alternate installation media and Linux Mint (although initially based on Ubuntu) doesn't provide an alternate install. I found a guide on the Linux Mint forums which can be followed to manually configure software RAID during installation. Linux Mint's immaturity as an OS reared it's ugly head when I neared the end of the install and the installer wouldn't let me proceed. Long story short I ended up installing Ubuntu 11.10 using the alternate install media and had a software RAID system up and running in about 20 minutes.

Monday, February 7, 2011

Converting from mbox to Maildir with Postfix and Dovecot on Debian

This is the procedure I used for converting from mbox to Maildir with Postfix and Dovecot running Debain 5.x. This assumes that you have individual system accounts for each mail user and that the mbox files are currently in /var/spool/mail/USER and /home/USER/mail/FOLDERS.

All the following commands/edits will need to be done as root:

Install mb2md:

aptitude install mb2md

Stop the mail servers:

/etc/init.d/postfix stop
/etc/init.d/dovecot stop


Edt the /etc/posfix/main.cf:

home_mailbox = Maildir/

Edit the /etc/procmailrc (if you are using procmail for local delivery/filtering):

ORGMAIL=$HOME/Maildir/
MAILDIR=$ORGMAIL
DEFAULT=$ORGMAIL


Edit the /etc/dovecot/dovecot.conf:

mail_location = maildir:~/Maildir

At this point I'd backup the user accounts just in case there is an issue.

Create a bash script with the following and execute it:

for i in $( ls -1 /home ); do
su -l -c 'mb2md -m' $i; ## convert /var/spool/mail/USER
su -l -c 'mb2md -s mail -R' $i;
done


At this point you will need to restart the mail servers:

/etc/init.d/dovecot start
/etc/init.d/postfix start

Tuesday, January 26, 2010

Correct way to install Firefox 3.6 on Ubuntu 9.10 Karmic Koala

First close all your current firefox windows. Then open a Terminal with Applications > Accessories > Terminal. At the $ prompt enter the following:

sudo add-apt-repository ppa:mozillateam/firefox-stable

When prompted for your password enter it and enter the following commands one on each line:

sudo apt-get update
sudo apt-get install firefox-3.6

Enjoy.

Wednesday, September 2, 2009

Finding perl packages with APT

If you are attempting to satisfy dependencies for perl software that was NOT available via your favourite repository (this is sometimes unavoidable in enterprise environments) you should AT LEAST attempt to satisfy those dependencies using said repository. The easiest solution is to install 'apt-file' from your repo and for any perl modules you can simply call:
apt-file search "LWP::UserAgent"

This will return the following list on Debian Lenny:
liblwp-useragent-determined-perl: /usr/share/man/man3/LWP::UserAgent::Determined.3pm.gz
libtest-mock-lwp-perl: /usr/share/man/man3/Test::Mock::LWP::UserAgent.3pm.gz
libwww-perl: /usr/share/man/man3/LWP::UserAgent.3pm.gz

Now you know that in order to satisfy a dependency on "LWP::UserAgent" you would need to install the 'libwww-perl' module from the repo.

If the module is not available via the repo you should next consider installing the package into a custom perl lib directory specifically for the software (and/or user account) in question. To do this read the documentation for the local::lib module in CPAN.

Ultimately your goal should be to not install non-packaged software to /usr/local and by doing so increase the maintainability of your systems.

Tuesday, July 7, 2009

Updating bios and/or firmware on Dell servers running Debian or any unsupported OS

These instructions will help you update BIOS, BMC, PERC or any other system firmware on your Dell system running any supported or unsupported OS.

I finally got around to updating our servers to Debian Lenny. We have 1850's and 2850's. After lots of trial and error I figured out how to go about updating the bios and various device firmware without a Dell supported Linux environment installed on the server. You should note that instructions below still require basic Linux experience. Another note is that these instructions are OS agnostic and use a livecd which doesn't care what operating system you actually have installed on the machine itself.

The first step is running the Dell Content Manager to create a custom update repository for your severs. The fun part is actually getting your hands on the thing. You will need to download the Dell Systems Build and Update Utility. I should note that I wasn't able to get the download to work until I tried with a MS Windows desktop. When/If you are prompted for a Service Tag, just enter one for one of your own servers.

Once the ISO is downloaded you'll need to mount/copy or extract the 'contentmanager' directory onto your desktop. Assuming you are moving forward with the Windows desktop route you'll want to run the 'win\wincontent.exe' (there is also a 'lin\lincontent.tar' if you want to try that, I didn't). Now go find the new directory that was created. Edit the content.ini and change the 'ftp://' url to 'http://'. After you save that, run the 'contentmanager.exe'. Select 'Create Custom Server Update Utility' and 'Next.' Click 'Browse' and select a directory to dump this repository and click 'Next.' Wait for the program to download some meta-data and then un-check 'Windows' (leaving 'Linux' checked). Now control-click all the server models you need to upgrade and click 'Next.' Go get a soda and let it download everything. Once you've got your 'CustomRepository' go into the 'repository/sysman' directory and edit the .XML files in that directory with your favorite editor and look for the 'path=' attribute(s) (one for each system type). You'll see something like 'path="sysman\..."' change the slash to a '/' so it'll look like 'path="sysman/...". Save your changes and copy the contents (not the directory itself) of the 'CustomRepository' to the root of a FAT32 formatted usbkey.

Now you need to download the OpenManage Server Administrator. Burn it to a CD and then boot it in one of the servers you want to upgrade. Let it boot up all the way (this can take several minutes while network connectivity times out etc. and you answer a couple questions) and once you login as root you need to insert the usbkey. Mount it (you can check 'dmesg' output for the device and it'll be the first partition on there) with something like 'mkdir /media/disk; mount /dev/sdb1 /media/disk -o ro'. Change directory into '/media/disk' and run the following './suu -u'. Wait for it to analyze your system and update your system to the newest bios and firmwares. You'll probably see some notifications from snmpd and other stuff, they can be ignored. After you've completed all the updates type 'reboot'. Do not power down your system, some of the updates need the system to be rebooted to complete (such as BIOS updates).

You should now have up-to-date hardware bios/firmwares for your server. I should point out that under the Drivers section for your Service Tag on Dell's site you might also see something about 'SCSI Drives' firmware update. If you are using SCSI drives in your system you might want to get these out of the way as well. There is a Windows .exe you can download which will create a floppy or ISO image which you can boot in your server to update the drive firmware.

I hope this helps out, this was the simplest solution I could find given my environment (no DVD drives, no network connectivity, and the livecd not supporting X on the 1850's). Good luck! :)

Monday, October 3, 2005

Fedora Core one last time

This is my last post about this disaster of a linux distribution.

  • Install 2 Package(s)

  • Update 39 Package(s)

  • Remove 0 Package(s)

  • Total download size: 92 M

Friday, September 16, 2005

Fedora Core (2.5 weeks later) again

I thought I should keep this joke running because that's what it is really; a complete  joke. Why do they even bother having releases? I had to double check to make sure I wasn't tracking rawhide. Just because its F/OSS doesn't mean it has to suck guys.

  • Install 1 Package(s)

  • Update 60 Package(s)

  • Remove 0 Package(s)

  • Total download size: 88 M

Monday, August 29, 2005

Fedora Core (2.5 weeks later)

Time for another FC4 update a couple weeks later.

  • Install 3 Package(s)

  • Update 38 Package(s)

  • Remove 0 Package(s)

  • Total download size: 151 M


Here piggy piggy piggy. Come on piggy!

Thursday, August 11, 2005

Fedora Core

I decided to run an update on my FC4 box today after about 3 weeks of being away from my desk.

  • Install 2 Package(s)

  • Update 85 Package(s)

  • Remove 0 Package(s)

  • Total download size: 226 M


Anyone who uses this OS and doesn't feel like a complete guinea pig please raise your hand. :)

Thursday, May 5, 2005

Fedora Core 3 (Ok, so maybe not)

I went back to FC3 at work. FC4T2 is showing a bit more promise as well. I liked Ubuntu but its very young, and has almost no configuration tools. They use gnome system tools for most stuff, which at best are flaky. Oh well, it was worth a try :) I still stand by the Debian on the server though. 9000 packages are hard to ignore.

Thursday, March 17, 2005

Fedora Core 4 Test 1

Well, I think they've done it. FC4T1 is officially the most unstable and most broken test/beta/alpha software I've had the pleasure to install. To make matters worse the development repo is usually out of sync which means you cant do a dist upgrade because of unfilled dependancies. I've been a big Redhat advocate since the RH3 days. I'm pretty much all but convinced that Debian on the server and Ubuntu on the desktop might be the ultimate combo. The only thing really missing from a major linux distro is some kind of binary diff so updating a system can happen as quickly as possible.

Monday, September 27, 2004

Well I finally did it

My IBM A21p came with a 3com 3c556b mini-pci combo card. Its never worked all that great with linux. Not that I've ever used it all that much, the 3com modem is completely unsupported by linux (way to go 3com, I love you). I was able to accept that because god forbid I'm not always on broadband :). The ethernet card on the other hand worked. The kicker was that I always had to disable acpi with acpi=off on all my linux installs for recent 2.4 and the entire 2.6 release since the test versions. NOW, the most recent versions of the linux kernel break REGARDLESS of the acpi parameter.

I did some poking around and found out that you can easily replace these pci cards and I knew that some versions of my laptop (A21p 2629, mine is the HWU version) came with an intel ethernet/lucent modem combo that works great with linux. Sure enough, according to ibm's website there are a few different cards that are field replaceable in the A21p line (and many other lines for that matter). Over to ebay and in 10 minutes I've got a used 06P3809 (ibm part number) mini-pci combo card ordered and it only set me back about $20 bucks shipped.

Installed it today and suprise suprise, it works flawlessly. I haven't tried out the modem, but all reports seem to indicate that it works fine. I guess none of this changes the fact that this broke completely between a STABLE release of linux. Oh well, sucks to be me. Atleast now I don't have to dick with the acpi=off thing.

Friday, September 10, 2004

acpi=off

Ya know the thing that ticks me off about linux sometimes? If your hardware
is too old, forget about it. If your hardware is too new, forget about it.
Hopefully one day hardware vendors will step up to the plate and just make
their stuff work properly. Ya ya, learn how to hack the kernel. I just want
an OS that works and isn't proprietary is that so much to ask? Oh yeah. So
anyway, the reason I'm bitching is cuz my laptop's ethernet has been broken
with acpi enabled since 2.6 came out. :)

SMB broken

Man, I wonder if they are ever going to get the gnome vfs stuff right. SMB shares: broken, sftp: broken, etc. Come on 2.8, where are you.