hi ,
i need to run a script that delete files when i logout as a user other than root user .
I have tried out using .bash_logout but that doesnt seem to work , so any alternative for this to be done.
Thanks in advance,
Harsha
hi ,
i need to run a script that delete files when i logout as a user other than root user .
I have tried out using .bash_logout but that doesnt seem to work , so any alternative for this to be done.
Thanks in advance,
Harsha
You can set a trap in /etc/profile:
trap 'rm -f $HOME/.dotfile1 $HOME/anotherfile; exit 0' 0
The trap for "signal 0" will be executed when the shell exits.
Thats true , but what i need is ,
to write the 'trap rm' command (as mentioned in your reply ), in the file which is accessible by a normal user .
I need to insert this command through my program as a normal user.
(/etc/profile can be changed only by the root!!)
Is there any way out for this prob?
Did you source the .bash_logout file..?
If source option is not avalaible, depending on your OS, try this:
~./bash_logout
If you want to set a trap for a single user, you can add it to the user's $HOME/.profile
Perhaps you could explain a bit more about the problem you are trying to solve.
If you are using bash and the .bash_logout is not being executed, that is of course also something to look into.
Need to make a script run from my program which deletes certain files as and when the user logouts from the GNOME log screen.
This program is run by a normal user (not the root user).
If I write the required commands in $HOME/.profile , the files get deleted when ever the user logs in again , but i need to delete the files immediately after the user logs out.
i believe .bash_logout doesnt not work if we use GNOME log screen for logging off.
You cannot really hook into the shell's login/logout scripts, as those are not invoked the way you would expect in Gnome. In particular, the user might login over the network, and/or run multiple terminals in the Gnome session, each of which is a separate shell session.
Instead, look into how GDM handles X sessions (or your login manager, if it't not GDM).