我的操作系统是mint 17.2
首先,当我开始时:
sudo /etc/init.d/lsyncd start
开始。
但是当我重新启动系统时,默认情况下它不会启动。我如何让它在启动时启动?
我之前曾把它作为一份新贵的工作,但在初创公司时也不起作用。
这是我的文件/设置:
/etc/init.d/lsyncd
#! /bin/sh
### BEGIN INIT INFO
# Provides: lsyncd
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: lsyncd daemon init script
# Description: This script launches the lsyncd daemon.
### END INIT INFO
# Author: Ignace Mouzannar <[email protected]>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="synchronization daemon"
NAME=lsyncd
DAEMON=/usr/bin/$NAME
CONFIG=/etc/lsyncd/lsyncd.conf.lua
PIDFILE=/var/run/$NAME.pid
DAEMON_ARGS="-pidfile ${PIDFILE} ${CONFIG}"
SCRIPTNAME=/etc/init.d/$NAME
NICELEVEL=10
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Exit if config file does not exist
[ -r "$CONFIG" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \
--test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--nicelevel $NICELEVEL --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
}
#
# Function that stops the daemon/service
#
do_stop()
{
start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) log_end_msg 0 ;;
2) log_end_msg 1 ;;
esac
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) log_end_msg 0 ;;
2) log_end_msg 1 ;;
esac
;;
status)
status_of_proc $DAEMON $NAME && exit 0 || exit $?
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
:
/etc/lsyncd/lsyncd.conf.lua
settings {
nodaemon = false,
statusFile = "/tmp/lsyncd.stat",
statusInterval = 1,
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd-status.log"
}
sync {
default.rsync,
source = "/home/user/bin_pers/data",
target = "/home/user/test",
delay=0,
rsync = {
perms = true,
owner = true,
archive = true
}
}
空文件 /var/log/lsyncd/lsyncd.log /var/log/lsyncd/lsyncd-status.log
答案1
事实证明,它没有启动,因为其中一条规则涉及启动时未安装的 HD。安装然后重新启动 lsyncd 就可以了。