I'm trying to run a script calling
systemctl from crontab but the command is not being executed. Other scripts work fine from crontab. The script works when executed in a terminal.
This is the script:
#!/bin/bash date &>> ~/Desktop/logs/resiliostatus.txt systemctl --user status resilio-sync | sed -ne '1,3p' &>> ~/Desktop/logs/resiliostatus.txt exit 0
This is the output to my logfile:
Thu Jan 17 02:17:17 CET 2019 ● resilio-sync.service - Resilio Sync service Loaded: loaded (/usr/lib/systemd/user/resilio-sync.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2019-01-17 01:01:55 CET; 1h 15min ago Thu Jan 17 03:00:01 CET 2019 Thu Jan 17 04:00:01 CET 2019 Thu Jan 17 05:00:01 CET 2019
The first entry is how it should look like when called from the terminal. But as you can see the calls from crontab only execute
date and not
This is how crontab looks like:
SHELL=/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/lib/systemd # m h dom mon dow command */15 * * * * /root/Desktop/backupscripts/cputempscript */30 * * * * /root/Desktop/backupscripts/ipdnsscript 0 * * * * /root/Desktop/backupscripts/ntpscript */5 * * * * /root/Desktop/backupscripts/resiliostatscript 2> /tmp/error
The first three scripts work fine, the last one doesnt.
The error I save to /tmp/error:
Failed to connect to bus: No such file or directory
- I'm logged in as root. No other user is logged in. Crontab is configured as
sudo crontab -e
- Environment: Kali Linux (re4son kernel, sticky-fingers) on RPi 3B+
- I read this similar thread but it is also unresolved.
How can I fix this?