Previous Section  < Day Day Up >  Next Section

Recipe 16.7. Launching the rsync Daemon at Startup

16.7.1 Problem

You don't want to start the rsync daemon by hand all the time. But rsync does not come with an init script. How do you make it start at boot time?

16.7.2 Solution

Put this script in /etc/init.d, then add it to your desired runlevels:

#!/bin/bash

# simple init script to run

# rsync in daemon mode

   

case "$1" in

    start)

        echo "Starting the rsync server..."

        exec /usr/bin/rsync --daemon 

        ;;

   

    stop)

        echo "Stopping the rsync server...."

        killall /usr/bin/rsync

        ;;

            

    restart)

        $0 stop

        sleep 1

        $0 start

        ;;

        

    *)

        echo "Usage: $0 {start|stop|restart}"

        exit 1

        ;;

esac

16.7.3 Discussion

Remember to chmod +x to make this script executable.

16.7.4 See Also

  • Chapter 7, to learn how to add rsync to your desired runlevels

    Previous Section  < Day Day Up >  Next Section