Debian systemd run process at startup

This is a copy of: (because it disappeared).

Run Script at Start on Debian/Ubuntu

July 3, 2013

Updated: Dec 12, 2015

Determine Init System

Newer installs use systemd as the init system, which has a newer and more
consisten way to manage services. There was a lot of linux drama around this
change, my guess mostly due to "cheese moving" and having to learn something

You can determine if your system is running systemd using: $ ps -p1

Start Daemon on System boot

The main reason I need this script is becaues BitTorrent Sync is not distributed as an Ubuntu package with necessary start scripts. Also, btsync needs to run as the user, which I often forget. First create the service file which describes how to start and information about the service.

Saved to: /etc/systemd/user/btsync.service

Description=BitTorrent Sync Service

ExecStart=/home/mkaz/bin/btsync --config /home/mkaz/.btsync.conf



sudo systemctl enable /etc/systemd/user/btsync.service


sudo systemctl start btsync.service

That's it, it should be running now and each time you start. You can test by rebooting and confirming it works. The above is not ideal for multi-user servers, since I'm hardcoding everything to my user, adjust to your needs.


There is a lot more information available around systemd and a lot more
configuration available for example to execute a command before start, or other

systemd throttling too fast - debian jessie bug

Systemd looks nice, but makes a lot more trouble than it helps (according to me).
There is a nasty bug in current jessie systemd 215 which makes it from time to time to say:
systemd[1]: Looping too fast. Throttling execution a little.
and eats up cpu.

The only way I've found, to solve temporary, without reboot is

#> systemctl daemon-reexec

Sniffing Unix Socket - debugging communication between nginx and php-fpm

Ever wondered how to sniff communication of a unix socket?
Here's how:

#> socat -t100 -x -v UNIX-LISTEN:/var/run/php5-fpm.sock.socat,mode=777,reuseaddr,fork UNIX-CONNECT:/var/run/php5-fpm.sock

You can remove -x and just leave -v for ascii communication.
Hope that helps someone.