Linux Training

Linux training for private, public & voluntary sector.

0800 024 8425

City LinUX sample scripts - bflsync


bflsync - use rsync to synchronise filesystems from belfields.belfld to bfl-uw.belfld.local.


bflsync [[ -c config ] [ -d ] [ -e <mail_address> ] [ -q ]] | [ -V ] | [ -s ]


bflsync is a Borne shell script which should work equally well on all versions of UNIX, Linux and Mac OS X.


bflsync reads the configuration file /usr/local/etc/ to determine which file systems need to be synchronised. Each remote file system is mounted using NFS and a local synchronised copy taken. The file system is unmounted immediately after synchronisation.

The script pauses after each complete cycle for a period determined by the configuration file.

Logging is done to the file /var/log/bflsync# where "#" is the number of the day in the week and Monday is designated day 1.

-c <config_file> Use config_file rather than the default configuration file /usr/local/etc/ .

-d Sets the debug option on. Every line of code is echoed to standard error before being run.

-V Print the release details for the instance of bflsync run.

-s Print the current config to standard out and quit.

The script is designed to work as a daemon process and should always be started with the init\r script. Other options to the init script are:

start The script is started in quiet mode.

monitor The script is started in verbose mode. The output to standard error will be redirected to /var/log/bflsync .

stop Signal 15 is sent to the bflsync process. The signal is trapped and the script waits until the current filesystem synchronisation is complete before it terminates. It may be over an hour before termination, if the file system is " datac " and the synchronisation has only just started.

halt This option should be avoided if at all possible. Signal 9 is sent to the running script process. An attempt will be made to stop the associated rsync processes but this cannot be guaranteed and the result may be messy. The lock file will be left in place. It is incumbent on the user to remove the lockfile and ensure all existing rsync processes are terminated before recommencing operations.

reload Signal 1 is sent to the running bflsync process. The signal is trapped until the current rsync is complete, the script then read reads the configuration file before starting synchronisation of the next filesystem.

remonitor Signal 15 will sent as restart below but when restarted the script will be in verbose mode and the output to standard error will be redirected to /var/lob/bflsync.out .

restart Signal 15 will be sent, as in stop above but the init script will then wait until the lock is removed and then attempt to restart bflsync .


/etc/init.d/bflsync start

If there is no existing lockfile start bflsync

/etc/init.d/bflsync stop

Stop the running instance of bflsync as the earliest opportunity.

/etc/init.d/bflsync reload

Signal the running instance of bflsync to re-read the configuration file as soon as possible.


/etc/init.d/bflsync, .IR /usr/local/etc/ .IR /var/log/bflsync[0-6] .IR /var/run/bflsync


Halting bflsync has unpredictable results.


Clifford W Fulford, City Linux. Contact or +44 (0)793 572 8612 $Id:,v 1.11 2017/03/05 12:23:15 fulford Exp fulford $

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.