I'm a beginner to Ubuntu, working on a script to save the current user name in a file in /tmp.. Previously I've used /etc/gdm3/PostLogin/Default script to do this
echo " $current_user" > /tmp/postlogin.log
and it worked well. But when we switch between users the file is being over-written and when we switch back to the previous user, it's not being updated, as the postlogin script is run only at logins.
Suggest me someway around this issue, which files I can use to make this script run. P.S. I've tried editing /etc/bash.bashrc , .profile, .bashrc and other related files to run my script and made a huge mess of things.