I've got a problem whereby if I run my bash script myself unison works as expected, when systemd runs it via a service on a timer then it does not work as expected. I'm logging the output of the unison executable and it comes back with nothing. What could be happening here?
The script in question is this...
#!/bin/bash echo "`date -u` `unison "USB Work" -batch`" >> /home/tom/timer.log
...which when run from the commandline works perfectly. The file is /usr/local/bin/unison.sync.usb-work.
My service /etc/systemd/system/unison-timer-usb-work.service looks like this...
[Unit] Description=Unison timer - sync work to USB [Service] Type=simple ExecStart=/usr/local/bin/unison.sync.usb-work
...the service is run every 10 minutes successfully by the following timer (etc/systemd/system/unison-timer-usb-work.timer)...
[Unit] Description=Runs Unison USB Work sync script every 10 mins [Timer] # Time to wait after booting before we run first time OnBootSec=1min # Time between running each consecutive time OnUnitActiveSec=10min Unit=unison-timer-usb-work.service [Install] WantedBy=multi-user.target
All of this appears to be set up correctly, systemctl list-timers shows it as active...
NEXT LEFT LAST PASSED UNIT ACTIVATES n/a n/a lun 2015-08-03 08:50:25 CEST 8h ago ureadahead-stop.timer ureadahead-stop.service lun 2015-08-03 17:00:40 CEST 9min left lun 2015-08-03 16:50:40 CEST 30s ago unison-timer-usb-work.timer unison-timer-usb-work.service
...and the /home/tom/timer.log file gets new blank entries with a timestamp every 10 minutes.
Why does the script work from the terminal (without sudo and with sudo) and not from the timer?!
Thanks in advance for any help,