I am trying to create a service on my Debian Wheezy system.
When trying to use start-stop-daemon to run autossh, the pid contained into the pidfile does not match with the autossh process.
$ AUTOSSH_PIDFILE=/var/run/padstunnel.pid
$ sudo start-stop-daemon --make-pidfile --background --name mytunnel --start --pidfile /var/run/mytunnel.pid --exec /usr/lib/autossh/autossh -- -M 0 -p 22 user@server -f -T -N -R 31022:localhost:31222
$ ps -elf |grep autossh
1 S root 447 1 0 80 0 - 329 pause 19:07 ? 00:00:00 /usr/lib/autossh/autossh -M 0 -p 22 ...
$ cat /var/run/mytunnel.pid
446
This behaviour prevents from stopping autossh
using start-stop-daemon or kill it using the pid from the pidfile.
Is there any reason to this behaviour ?
How to workaround it and make autossh's pid matches the pidfile ?