Need to track what Commands run in a login session

Hi

I need to track what commands run in login session in solaris whether it is root or any normal users in bash shell.

My actual requirement is that when a user (nomal/root) login into the system, whatever commands he run, it should log into file on specified path . I don't require command outputs. I want that in a below format.

<date and time of command run> <Actual command run along with it argument>

As I am novice in shell script, please help me in creating the same. I don't want to use snoopy or any other tool due to some constraints just want to use script for implementing the same

Regards

Did you have a look at auditing on Solaris?
Oracle Solaris Audit Quick Start
Auditing (Overview) - Oracle Solaris Administration: Security Services

How far would setting the bash shell variable HISTTIMEFORMAT get you?

2018-09-02 11:07:06 HISTTIMEFORMAT="%F %T "
2018-09-02 11:07:08 history 5
2018-09-02 11:08:58 cat ~/.bash_history 
2018-09-02 11:09:19 history | less

You could append the history command's output to your log file periodically, and / or in ~/.bash_logout .

thanks Scrutinizer for sharing the link. Yes I knew about this Solaris feature but I was more interested to implement in Script form as if got successful then I can go for implementation in Linux as well. Further this tool generate log of logs and it might bring impact on performance and bit complex to fetch the require details My only requirement is that I need what commands user has run in his session.

Thanks RudiC for sharing this idea, could you please explain how can I implement it in term of code at global level further current session commands with time should go to in a file saved with username-with logout time.

Thanks Scrutinizer & RudiC for your idea again and I would appreciate it further if you help in this further creating the script.

Where are you possibly stuck?