0

I'm having trouble getting a service to run on boot and shutdown. After boot, I query with systemctl status scrThunderbirdProfileSync and get

systemctl status scrThunderbirdProfileSync
● scrThunderbirdProfileSync.service - Script to sync Thunderbird Profile to msc004
   Loaded: loaded (/etc/systemd/system/scrThunderbirdProfileSync.service; enabled)
   Active: inactive (dead)

If I try systemctl start scrThunderbirdProfileSync it works fine. journalctl | grep scrThunderbirdProfileSync yields nothing except when I manually start the service.

Where am I going wrong? Is there any glaring errors? Should I be looking at two separate services, one for boot, one for shutdown? Note that I've chosen SystemD over my KDE's autostart etc as occasionally kde freezes when logging out and I have to manually shutdown the service kdm.

CONTEXT:

I'm trying to sync Thunderbird data between two desktops (which are only on when I need to use them) and a mini-desktop (which is always on).

There are similar scripts on both desktops, they should trigger on boot to download latest data from the server and upload and newer files that haven't been uploaded, repeating when the desktop shuts down.

METHOD:

SCRIPT:

echo "1: Starting Sync > upload..."
rsync -avzhu --progress /home/username/.thunderbird -e ssh root@server:/mnt/local/data/Personal/Thunderbird/
echo "2: Starting Sync > download..."
rsync -avzhu --progress -e ssh root@server:/mnt/local/data/Personal/Thunderbird/.thunderbird /home/username/

SERVICE FILE:

[Unit]
Description=Script to sync Thunderbird Profile to server
DefaultDependencies=no
Before=shutdown.target reboot.target halt.target kexec.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/scrThunderbirdProfileSync
ExecStop=/usr/local/bin/scrThunderbirdProfileSync

[Install]
WantedBy=halt.target reboot.target shutdown.target kexec.target
  • Couldn't get this to work, so changed to two services an '_ONBOOT' and '_ONSHUTDOWN',m which works fine. It may help that I've minimised the work the triggered rsync has to do, so only lasts about 20 seconds now, rather than 10 minutes previously. – aSystemOverload Jun 21 '18 at 21:24
1

Check your logs, maybe you need to wait for network

After=network.target

Don't forget to check your logs with

sudo journalctl -u scrThunderbirdProfileSync

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.