Sample Header Ad - 728x90

Using Cron to restart a systemd user service

11 votes
2 answers
5998 views
I have created a --user service in systemd such that a non privileged user can manage a service. This works well. I wanted to restart the service at a fixed given time of day, so i created a cron job in the users crontab. Strangely this does not work. The user can restart the service if they run: systemctl --user restart myservice.service However running this from the crontab does not restart the service. Does anyone know why? This is running on Ubuntu 16.04.
Asked by Magnus Jørgensen (113 rep)
Oct 10, 2018, 08:30 AM
Last activity: Apr 28, 2025, 07:05 PM