2

Users on a linux (CentOS4) machine I administer consistently forget to empty the trash. Since the people work on big files, this can fill up the /home partition very quickly.

Therefore, I would like to create a script that automatically empties the user's trash whenever they log out.

How would I do that?

EDIT I guess I should clarify the situation a little: The computer is attached to a microscope. Users come, log on, take pictures (storing them on the generous scratch space during acquisition), and then they transfer the data onto the server.

Sometimes it happens that pictures that looked good at first glance are crap, so the users delete the pictures - which sends them to the trash in /home - instead of moving them to the server. Or they copy the data instead of moving, and then they delete it later.

Eventually, they log off so that someone else can use the microscope. If they just filled up /home with their trash, the next person cannot launch the acquisition program, which means that I have to go empty the trash, and since the microscope is used almost 24/7, this may happen at rather inconvenient times (in addition to possibly cancelling a microscopy session for the user).

To avoid these problems, I want to make sure that the trash can is emptied whenever a user logs off, so that the next user can get their work done.

2 Answers 2

2

I really don't like the idea of you meddling with user files. They are the ones who know what to keep and what not to keep. Who knows, maybe they use their Trash folders as tmp folders.

What I would do instead:

  • restrict how much space they have with disk quotas. This needs to be as much as you want to afford.
  • provide them with additional "scratch" space. This should be plenty of space, but I would implement a cron job that periodically deletes files not accessed in a long time (tmpreaper actually has all that built-in with some extras).

Then you also wouldn't have to worry about people like me who would immediately remove your modifications to my login/logout scripts.

3
  • 1
    In principle I agree - it's preferable to give the users some autonomy. However, this is a special case: There is 1.5T of (shared) scratch space, where users can store their temporary data before they move it away onto the server. And if I was to limit their quotas on /home, users would come to me complaining that they don't have anymore space, and I would have to tell them to take out their trash.
    – Jonas
    Mar 20, 2010 at 23:04
  • 1
    They will learn quickly to worry about this if they cannot get any work done. If they cannot login anymore because they used up their quota, make them wait half a day. If you would do what you plan to do to me I probably would just lock the session instead of logging out. Mar 20, 2010 at 23:09
  • I agree with both of you, but I also recommend this "HowTo deal with Users" :D baetzler.de/humor/sysadmin_from_hell.var
    – dag729
    Mar 20, 2010 at 23:14
0

Implement the ~/.bash_logout file in the users directory and trigger clearing of Trash there, if you really wish to.

You should also look at the documentation of the Desktop-Environment for recommended Logoff-scripts - most desktops support such a feature.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .