trash -f filename_1 { filename_n }
When a file is "trashed" with the trash -f file command instead of using the rm command, the following actions take place:
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.
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 ).
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
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.