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!

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

Update Group Policy Templates

If you are using Windows 7 clients on your network and wish to manage them fully via group policy you may have noticed that some of the new GP items are missing from your Group Policy Managament Console. This happens when you are running a Domain Controller that is not Windows 2008 R2.

Don’t worry its really easy to copy the newer group policy templates over to your DC, whether it be Windows 2003 or 2008.

Execute the following 2 commands on a Windows 7 workstation:

xcopy %systemroot%\PolicyDefinitions\* %logonserver%\sysvol\%userdnsdomain%\policies\PolicyDefinitions

xcopy %systemroot%\PolicyDefinitions\EN-US\* %logonserver%\sysvol\%userdnsdomain%\policies\PolicyDefinitions\EN-US\

This will copy all the updated ADMX and ADML files to your DC.

This should take but seconds, now when you access GPMC you will have a full set of Group Policy objects to look at.
 

You may also like to install the Remote Server Administration Tools (RSAT) on your Windows 7 workstation, visit the link below to download:

http://www.microsoft.com/downloads/details.aspx?FamilyID=7D2F6AD7-656B-4313-A005-4E344E43997D&displaylang=en