Logrotate – mysql error – Ubuntu

I have been setting up some new server recently and ran accross this error happening in the daily cron jobs:

/etc/cron.daily/logrotate:
error: error running shared postrotate script for '/var/log/mysql.log
/var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log '
run-parts: /etc/cron.daily/logrotate exited with return code 1

Using phpmyadmin on the server shows that the debian-sys-maint user is correct and has all permissions, so I can only assume the password has some how got mangled in all the upgrading process.

You should find you have a file:

/etc/mysql/debian.cnf

 # Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = XXXXXXXXXXXXXXXX
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = XXXXXXXXXXXXXXXX
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

If you have deleted or have lost the debian-sys-maint user then you need to recreate it with:

GRANT RELOAD, SHUTDOWN, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY PASSWORD 'xxxxxxxxxxxxxxxx'

Else simply update the password

 UPDATE user SET Password=PASSWORD("xxxxxxxxxxxxxxx") WHERE User='debian-sys-maint';

And with any luck that should be you back on the road to logrotate!

Startup scripts – add windows features

Quick update for January!

It is easy to control Windows 7 features by turning them on and off by startup scripts. Pop along to your group policy and add the following script to add the Games features back into Windows 7 Enterprise (default is not to install games – how boring!)

REM Install Games
dism /online /enable-feature /featurename:"InboxGames" /norestart /quiet

You can control any features with this simply look up the featurename of the component you want to use.

View your currently installed features with:

dism /online /get-features

You may want to pipe that to something as it can be a long list!

Remote Desktop Connection

A cheeky little command I found out about.

Pressing CTRL + ALT + PAUSE/BREAK

This causes Remote Desktop connection to change from window mode to full screen. I found out the hard way that using my laptop to connect to server screens was causing the screen refresh and to resize.

One point to note is that on some laptops you may also need to press Fn, as BREAK is a secondary keyboard option (usually in blue).

Manage Windows Printers from command line script

Every now and again you come across the issue of printers…..

Most people in larger environment will use Group Policy to manage your printer deployment, certainly in Windows Vista/7 this was made a lot easier with the enhancement of group policy.

This script was included with Windows XP and has appeared in subsequent versions of Windows.

C:\>cscript %windir%\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs /?
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
Usage: prnmngr [-adxgtl?][c] [-s server][-p printer][-m driver model]
               [-r port][-u user name][-w password]
 Arguments:
 -a     - add local printer
 -ac    - add printer connection
 -d     - delete printer
 -g     - get the default printer
 -l     - list printers
 -m     - driver model
 -p     - printer name
 -r     - port name
 -s     - server name
 -t     - set the default printer
 -u     - user name
 -w     - password
 -x     - delete all printers
 -xc    - delete all printer connections
 -xo    - delete all local printers
 -?     - display command usage
Examples:
 prnmngr -a -p "printer" -m "driver" -r "lpt1:"
 prnmngr -d -p "printer" -s server
 prnmngr -ac -p "\\server\printer"
 prnmngr -d -p "\\server\printer"
 prnmngr -x -s server
 prnmngr -xo
 prnmngr -l -s server
 prnmngr -g
 prnmngr -t -p "\\server\printer"

A couple of handy commands to get you started

Remove all network connected printers:

cscript %windir%\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -xc

If you prefer your approach to be a little more precise, then below is the script I use for removing particular printers and their drivers from machine. Also a very handy way for dealing with 64 bit and 32 bit Windows printers….

rem Remove all Kyocera Drivers
 rem Check Environment
 IF NOT "%ProgramFiles(x86)%"=="" (goto ARP64) else (goto ARP86)
 REM 64 Bit
 :ARP64
 cscript %windir%\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs -d -m "Kyocera FS-2020D KX" -v 3 -e "Windows x64"
 cscript %windir%\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs -d -m "Kyocera TASKalfa 500ci KX" -v 3 -e "Windows x64"
 goto End
 REM 32 Bit
 :ARP86
 cscript %windir%\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs -d -m "Kyocera FS-2020D KX" -v 3 -e "Windows NT x86"
 cscript %windir%\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs -d -m "Kyocera TASKalfa 500ci KX" -v 3 -e "Windows NT x86"
 goto End
 :End

Outlook profile moving

Have you ever noticed that some users complain?

Outlook seems to be the most popular email client in the business world, however if you have users on one machine they usually want to have there settings on all machines. Roaming profiles is ideal for this however there are always times when you have to do it manually.

The most common bug bear from users is when you move ore re-create their profiles on another machine, outlook has “forgotton” then email contacts. ie Quick list that drops down when you start to enter an email address.

The reason for this is that this information is held in a file within the users folders, not in the PST file (if you are using PST), or Exchange.

To find this file you are looking for a file with the extension .nk2 the full name will be the Outlook profile name with the extension .nk2.

This file can usaually be found in:

Windows XP
Drive:\Documents and Settings\Username\Application Data\Microsoft\Outlook
Windows Vista and later versions
Drive:\Users\Username\AppData\Roaming\Microsoft\Outlook

If you have changed the profile name in Outlook when you set up the new account simply change the name of the .nk2 file to match.

NOTE that Outlook 2010 now stores this information inside the PST or Exchange mailbox. If you want to import these see the following link:
http://support.microsoft.com/kb/980542