I have Debian Jessie and connect to it by ssh. I want to autostart shell command on user login by systemd.
I've create a simple systemd service ~/.config/systemd/user/foo.service
witch contains:
[Unit]
Description=Systemd autostart test
Wants=local-fs.target
After=local-fs.target
[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo 123 >> /home/user/there;"
[Install]
WantedBy=multi-user.target
I've enable it by systemctl
systemctl --user enable foo
I've created success message container
touch ~/there
and after reboot and login (by ssh) ~/there
file is empty.
When I use it manually
systemctl --user restart foo
it works.
What am I missing?
systemd
normally does not allow ordinary users to start system services. Why not using.profile
?systemd
doesn't allow ordinary users to start system services, yes. But as is clear in the question, the user is callingsystemctl --user
, which is for user services, not system ones.