Chapter 24. Use systemd for user services

This is how to set up a user-specific automated systemd process, i.e., a way to replace startup scripts that used to live in /etc/init.d. This process should work for any user service; this example is for Dropbox.

  1. Stop existing services

    Stop any existing Dropbox processes

  2. Create a systemd user service

    mkdir -p ~/.config/systemd/user/

    cp ~/Dropbox/Basic/new_machine/linux/config/dropbox.service ~/.config/systemd/user

    Note

    dropbox.service

    [Unit]
    After=local-fs.target network.target
    Description=Dropbox as a user service
    
    [Service]
    Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
    Environment=DISPLAY=:0
    ExecStart=%h/.dropbox-dist/dropboxd
    Restart=on-failure
    RestartSec=1
    Type=simple
    
    [Install]
    WantedBy=default.target
    
    

    Source: archlinux forum.

  3. Test it

    systemctl --user start dropbox.service

    View the log with journalctl --user --unit=dropbox

  4. If it works, automate it.

    systemctl --user enable dropbox.service