login about faq

Hi,

I want to write authentication logs from MySQL to syslog. How to do it?

asked Sep 04 '12 at 11:45

anttisa's gravatar image

anttisa ♦
106252627

edited Sep 04 '12 at 15:16


Hi,

You can do it for example with small shell script and crontab.
1) Create script called log-script.sh to MobileID server that uses default database middb. Script will select authentication messages that are higher than the current time minus 1 hour

#!/bin/sh
#
USER="midd"
PASSWD="midd-password"
LOGFILE="/var/log/mobileid/my-log-file"

mysql -u $USER -p$PASSWD -e  'select * from middb.Access WHERE Time >= now() - interval 1 hour;' >> $LOGFILE

2) Change variables USER,PASSWD and LOGFILE.
3) Choose user that has write access to log file and create cron job

# crontab -e
0 * * * * /path/to/log-script.sh

4) Make sure that script have executable permissions

# chmod +x /path/to/log-script.sh

Now script is executed every hour. You can list your cron jobs with command

# crontab -l
link

answered Sep 04 '12 at 12:03

anttisa's gravatar image

anttisa ♦
106252627

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×55

Asked: Sep 04 '12 at 11:45

Seen: 1,819 times

Last updated: Sep 04 '12 at 15:16

All user contributed content licensed under the cc-by-sa license.
Powered by OSQA.