How to stop logging to user's home dir

I love syncthing, I am running it on a WD My Cloud server running Debian GNU Version 7 (with none of the WD software installed). The problem I have is that I am unable to stop logging to the user’s home directory. I want to redirect the logs to /var, which is in RAM, so the disk can spin down when there is no I/O. I am using ramdisk, btw.

Here is my /etc/init.d/syncthing:

#!/bin/sh
### BEGIN INIT INFO
# Provides: syncthing
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Multi-user daemonized version of syncthing.
# Description: Starts the syncthing daemon for all registered users.
### END INIT INFO

# Replace with users you want to run syncthing clients for
syncthing_USERS="kevinm"
DAEMON=/usr/local/bin/syncthing
DAEMON_START=/usr/local/bin/syncthing_start.sh

startd() {
  for stuser in $syncthing_USERS; do
    if [ -f $config ]; then
      echo "Starting syncthing for $stuser"
      start-stop-daemon -b -o -c $stuser -S -u $stuser -x $DAEMON_START
    else
      echo "Couldn't start syncthing for $stuser (no $config found)"
    fi
  done
}

stopd() {
  for stuser in $syncthing_USERS; do
    dbpid=$(pgrep -fu $stuser $DAEMON)
    if [ ! -z "$dbpid" ]; then
      echo "Stopping syncthing for $stuser"
      start-stop-daemon -o -c $stuser -K -u $stuser -x $DAEMON
    fi
  done
}

status() {
  for stuser in $syncthing_USERS; do
    dbpid=$(pgrep -fu $stuser $DAEMON)
    if [ -z "$dbpid" ]; then
      echo "syncthing for USER $stuser: not running."
    else
      echo "syncthing for USER $stuser: running (pid $dbpid)"
    fi
  done
}

case "$1" in
  start) startd
    ;;
  stop) stopd
    ;;
  restart|reload|force-reload) stopd && startd
    ;;
  status) status
    ;;
  *) echo "Usage: /etc/init.d/syncthing {start|stop|reload|force-reload|restart|status}"
     exit 1
   ;;
esac

From the above, you can see that stop and status use the syncthing binary which is in /usr/local/bin. Starting the daemon calls a script in the same directory called syncthing_start.sh and contains the following:

#!/bin/sh
# Script to make syncthing use syslog.
/usr/local/bin/syncthing  2>&1 | logger -t syncthing

I can see syncthing running two processes:

/etc/init.d/syncthing status syncthing for user: running (pid 32011 32012 32017) ps aux | egrep ‘32012|32012|32017’ user 32012 0.0 1.2 796676 2960 ? Sl 20:28 0:00 /usr/local/bin/syncthing user 32017 133 27.9 797188 64716 ? Rl 20:28 20:27 /usr/local/bin/syncthing root 32121 0.0 0.3 3100 704 pts/0 S+ 20:43 0:00 egrep 32012|32012|32017

and logger is running

ps aux | grep logger user 32013 0.0 0.2 2944 584 ? S 20:28 0:00 logger -t syncthing root 32213 0.0 0.3 3104 708 pts/0 S+ 21:00 0:00 grep logger

The problem is that syncthing still logs in a verbose manner to the user home directory in /home/user/.config/syncthing/index as well as just info messages /var/log via logger. How can I fix this?

The index you refer to is not logs, but the database of files. You can move it somewhere else with the -home flag to syncthing - although it should be somewhere persistent, not a RAM disk. The logging can be directed as you please via logger or syslog, but I guess that part is already as you like it?

Thanks for the quick response.

What I am looking to do is spin down the disk when the system is idle, but the constant writing to the home directory prevents this. At the moment I am stopping syncthing via cron at 11pm and starting it manually whenever I start work, usually around 4pm. I guess this is the way to leave it if ramlog is not an option (is this so, despite the fact that it reads from disk at startup and writes its contents back to disk at shutdown?)

Have you looked at https://github.com/syncthing/syncthing-inotify ?

It will enable you to disable rescans (which spin up the disk), and only scan when something happens to the filesystem

Looks perfect for my needs. Thanks.