Recipe 16.7. Launching the rsync Daemon at Startup

 < Day Day Up > 

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

     < Day Day Up > 


    Linux Cookbook
    Linux Cookbook
    ISBN: 0596006403
    EAN: 2147483647
    Year: 2004
    Pages: 434

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net