This may be considered a bit of a "hack", but FWIW:
I was slightly bothered by the fact that I had to add the "D-Bus environment" stuff from Stephen's excellent and correct answer to my script. So I'll propose another method that gets access to the "D-bus environment" as follows:
Open the root crontab, and add one line:
$ sudo crontab -e
# in the editor, add this line:
20 18 * * * su <user> -l -c </path/to/script>
# for example:
00 12 * * * su pi -l -c /home/pi/some_script.sh
# --OR--
@reboot su pi -l -c /home/pi/some_script.sh
Where some_script.sh contains one or more calls to :
systemctl --user <action> <servicename>
What's going on:
su means "run a command with/as a substitute user ..." (ref man su)
pi is just the name of an unprivileged user
-l start shell as a login shell (where the "D-Bus environment" is loaded)
-c pass the following command to the shell (in this case /home/pi/some_script.sh)
Why am I "bothered"?:
Maybe a personality quirk, but it seems to me that all software coming from RedHat is... "unconventional" (e.g. systemd, D-bus, etc)
crontab -l. You have to execute it as user which have permissions to this service. The other question is: why do you want to restart it using cron?