Linux Training

Linux training for private, public & voluntary sector.

0793 572 8612

City LinUX sample scripts - rclean

NAME

rclean - selectively archives and deletes old files on a remote host

SYNOPSIS

rclean [ -a <age> ] [ -c <config> ] [ -d ] [ -l ] [ -t ] [ -v ] <host_name>

AVAILABILITY

rclean is a Bourne shell script which should work equally well on all versions of UNIX and Linux.

DESCRIPTION

rclean Is a hardwired host specific script used to keep a remote server's file system reasonably tidy.

OPTIONS

-a #days Sets the minimum age threshold in days before files may be deleted. This value is normally set in the configuration file . The default is 100 days. Both the configuration file and the default are trumped by the command line option.

-c <config_file> The default configuration file is /usr/local/etc/rclean.cf . An alternative configuration file may be set with the -c    option on the command line.

-d sets the script to debug mode (ie. runs with the shell option -x)

-l    turns on logging using the syslog facility. This is particularly useful where statistics are being compiled for presentation to the client, see report.

Just to make life harder the logging is done by the remote host so that host's logging facility will need to be configured for remote logging as will the administration box's to allow it to receive the remote syslog messages.

-v Sets the script to verbose mode. Each significant action will be reported on standard out.

FILES

rclean.cf

EXAMPLES

5 0 * * * su - fulford -c "/usr/local/etc/rclean -a 8 albert"

The above is an extract from a root crontab file and illustrates the typical use of the script in practice. The files to be deleted or archived are specified within the script itself but the minimum age of the files before deletion is more flexible as it is specified on the command line and in this case is 8 days.

NB. The hostname albert is being resolved locally and does not require a fully qualified domain.

BUGS

The script is quite crude having been developed to address problems experienced by City Linux clients that were running out of disk space. The script does depend on very specific file names and paths. It could be made more generic by adding a configuration file.

SEE ALSO

chkdf, chkftpd, chkfw, secscan.

AUTHOR

Clifford W Fulford, City Linux. Contact fulford@fulford.net or +44 (0)709 229 5385.


The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.