I have written a c++ app that reads from a USB port. I also have a php daemon that calls this app every minute of every day. For each call, the following log gets written to the auth.log file:

Jan 23 07:09:09 [server-name] sudo:     root : TTY=unknown ; PWD=[path-to-app] ; USER=root ; COMMAND=[path-to-app]/relaymon r
Jan 23 07:09:09 [server-name] sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Jan 23 07:09:09 [server-name] sudo: pam_unix(sudo:session): session closed for user root

[path-to-app] replaces the real path in the log [server-name] replaces the true server name in the log

Can anyone tell me how I can configure the system to not generate these log entries please?

  • You think logging root logins is pointless? – ceejayoz Jan 22 '13 at 21:30
  • 1
    sudo logging is NOT pointless! – mdpc Jan 22 '13 at 21:33
  • no what is pointless is logging something that is automated and I know is running every time the daemon runs. hence the background in the question. I dont think at any stage I said I wanted to stop logging in general, just this command running from a daemon – Greg J Jan 22 '13 at 21:46
  • 1
    OP just wants to filter out these sudo entries. He is not debating whether they are pointless or not. – Chetan Bhargava Jan 22 '13 at 21:49
  • yes Chetan, correct, sorry if my question wasnt specific enough to say that. just wanted to stop a log being generated for this command running from within the daemon. – Greg J Jan 22 '13 at 21:53

Instead of disabling the logging, I would change your program to not require being run as root (might need to change device permissions) and change your PHP app to not call it with sudo.

  • yes I think I know where the problem is, the daemon runs as root anyway so there is no need for the command to contain "sudo". I will change the daemon and restart it to see if this works – Greg J Jan 22 '13 at 21:47

Personally anytime sudo is executed, I WANT to be informed and a log entry made. Thus I am confused and concerned about your choice and decision to attempt to suppress these entries.

However, (not recommended) you could configure syslog not to store these entries.

  • ah ok so its because the command contains sudo that the log is being generated? as the daemons run as root anyway, if i remove the sudo command from the line of code the logging should stop? – Greg J Jan 22 '13 at 21:36
  • yep, this is the case. – mdpc Jan 22 '13 at 21:38
  • ok, daemon updated and restarted and it works! thanks for pointing me in the right direction. Oh and thank you for reading the question, unlike some others that are quick to hit the keyboard before the brain engages – Greg J Jan 22 '13 at 21:56

You can use visudo and add this line to disable logging:

Defaults !syslog

This will disable ALL logging for all users.

There are examples/options in the sudoers man page to configure logging.

For example:

Defaults:php_user !syslog

should disable logging for only the php_user user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.