Thanks a ton my
serverfault friends for the answers.
I think i have come up with an answer for my question with all your help. But you all kinldy help me out if there is any error associated with it or any improvements to be done? Here i go.
These are the things i did.
i). created a script ,
datewrapper.sh in /etc with the following code
# wrapper script for the date command.
# whenever the date -s command is issued, it will be logged.
# executing the date command first with parameter list if any
# check whether the date command executed successfully
if [ "$?" == "0" ] ; then
for param in $@ ; do
# if "-s" option is used, log it
if [ "$param" == "-s" ] ; then
# user.notice logs the message to /tmp/log/user.log
# as per the commands in /etc/syslog-ng/syslog-ng.conf
logger -p user.notice "New date set"
ii). chmod a+x /etc/datewrapper.sh ; alias date='/etc/datewrapper.sh'
Tue Dec 21 21:51:01 UTC 2010
iv). date -s "21:53:05"
Tue Dec 21 21:53:05 UTC 2010
v). I checked the /tmp/log/user.log. It shows the message
Dec 21 21:53:05 localhost root: New
So the result is that whenever the user gives
date command, my script will be executed and whenever he issues the command with
-s option, it will logged into