trash

Package: WA2L/edrc 1.5.57
Section: General Commands (1)
Updated: 18 September 2006
Index Return to Main Contents

 

NAME

trash - move files to a central recycle bin (trash)

 

SYNOPSIS

edrc/bin/trash [ -h ]

trash -f filename_1 { filename_n }

 

AVAILABILITY

WA2L/edrc

 

DESCRIPTION

The trash and untrash command implement a trash can or recycle bin similar to the "Recycle Bin" of Microsoft Windows (TM) or the "Common Desktop Environment, CDE" (TM) as command line tools.

When a file is "trashed" with the trash -f file command instead of using the rm command, the following actions take place:

1.)
the file to be trashed is copied to a configurable trash location, that, of course, should have sufficient disk space.

An economic variant of such a trash location is an automounted NFS share, so a global trash for a whole environment can be used to put trashed files and the "wasted" disk space is in general not that huge. The trash and untrash commands are designed to handle a global trash due to the fact that the trashed file is associated with a node-, MC/ServiceGuard- or similar script cluster package name. See also trash.cfg(4) for information about the possible configuration settings and cltrash(1) for information about cleaning up the trash.

2.)
the file is emptied (not removed, to preserve the file handle).

3.)
the file is moved to file.TRASHED .

4.)
Now information about what has happened to the original file and how to retrieve it ( with untrash ) is written to file.TRASHED .


Therefore this command provides an easy and consistent way to "remove" files which, for example, cause filesystem fill ups, as database exports written to a to small filesystem, and transparently document to the end user what has happened to the file.

This is a more reliable method then the often used practice among system administrators to move the problem causing file to a filesystem with more disk space and to create a symbolic link to it, due to the fact that an end user might not notice that the file creation 1st, caused a problem and 2nd, the created file might be incomplete/corrupt due to an export or program abort because of the filesystem fill up. Furthermore often those symlinks and especially the moved files have the tendency to get forgotten to be cleaned up (because those interventions often happen during on call times) and lots of disk space is wasted over time.

Suppose the process that caused the fill up will restart and create a new file with the same name. If the system administrator again trashes the file, then two versions of the same file are available for retrieval (with untrash ).

 

OPTIONS

-h
usage message.

-f filelist
list of files to be trashed.

 

EXIT STATUS

0
no error.

1
LOGDIR or TRASHDIR does not exist. See trash.cfg(4) if you get this error.

2
operating system is not supported. See osid(3) if you get this error.

3
rootdir does not exist.

4
usage listed.

6
configuration file edrc/etc/trash.cfg does not exist.

 

FILES

edrc/etc/trash.cfg
configuration file for trash, untrash and cltrash.

edrc/var/trash/log/
default logfile location of trash, untrash and cltrash.

edrc/var/trash/files/
default location for trashed files.

filename.TRASHED
information and instruction file to document the file trashing and to give instructions how to recover ( untrash ) the trashed file.

 

EXAMPLES

1) trash a file:

1.1) list files in the directory:

        [ /data_dwh1/dat/exports ]
        [ root@dwh_db1_prod ][ksh]: ls -al

        :
        -rw-r-----  1 dwh_db1  dwh    17884 Jul  1 03:36 a_list.txt
        -rw-r-----  1 dwh_db1  dwh  4636592 Jul  1 03:34 dwhprod.dmp
        -rwxr-x--x  1 dwh_db1  dwh      500 Jul  1 03:35 export_dwhprod.sh*
        -rw-r-----  1 dwh_db1  dwh      250 Jul  1 03:35 exp.par
        :

1.2) trash the dwhprod.dmp file:

        [ /data_dwh1/dat/exports ]
        [ root@dwh_db1_prod ][ksh]: trash -f dwhprod.dmp  

        trash files ...
                remove dwhprod.dmp ... done.
        done.

1.3) situation in directory after invoking trash :

        [ /data_dwh1/dat/exports ]
        [ root@dwh_db1_prod ][ksh]: ls -al

        :
        -rw-r-----  1 dwh_db1  dwh    17884 Jul  1 03:36 a_list.txt
        -rw-r-----  1 dwh_db1  dwh      300 Jul  1 03:42 dwhprod.dmp.TRASHED
        -rwxr-x--x  1 dwh_db1  dwh      500 Jul  1 03:35 export_dwhprod.sh*
        -rw-r-----  1 dwh_db1  dwh      250 Jul  1 03:35 exp.par
        :

1.4) content of the dwhprod.dmp.TRASHED file:

        #
        # dwhprod.dmp.TRASHED - trash info file for trashed files
        #
        # [00] 01.01.2006       created by root using trash
        #

        The file:

            -rw-r-----  1 dwh_db1  dwh   4636592 Jul  1 03:34 dwhprod.dmp

        has been removed by administrator 'root'. To recover the file
        from trash, invoke:

                untrash -f dwhprod.dmp


 

SEE ALSO

cltrash(1), edrcintro(1), trash.cfg(4), untrash(1)

 

NOTES

To resolve the node- or MC/ServiceGuard package name the pkg_hostname(3) command is used. Therefore the usage of the trash command is not restricted to systems that have MC/ServiceGuard installed.

 

BUGS

-

 

AUTHOR

trash was developed by Christian Walther. Send suggestions and bug reports to wa2l@users.sourceforge.net .

 

COPYRIGHT

Copyright © 2008 Christian Walther

This is free software; see edrc/doc/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 

Index

NAME
SYNOPSIS
AVAILABILITY
DESCRIPTION
OPTIONS
EXIT STATUS
FILES
EXAMPLES
SEE ALSO
NOTES
BUGS
AUTHOR
COPYRIGHT

This document was created by man2html using the manual pages.
Time: 00:14:30 GMT, March 08, 2025