The series completes the tutorial Obsidian Sync. If implemented you can save few bucks every year and still have Obsidian Sync in cloud.
Create a timer
Test the status of
Test status of
Enable
comments powered by Disqus
This article is part of a series.
- Part 1: Obsidian Sync
- Part 1: Obsidian Sync script
- Part 2: Obsidian Sync as service

Table Of Contents
Service and Timer
Create a systemd service
and a timer
. The function of timer
unit is to trigger service
unit and the service
unit will execute the obsidian-sync
script
Timer Unit
Create a timer obsidian-sync.timer
unit
bash -c "cat >$HOME/.config/systemd/user/obsidian-push.timer" <<EOF
# Timer for obsidian-push.service
# By Munish Mehta
[Unit]
Description=Starts the obsidian-push.service
Requires=obsidian-push.service
[Timer]
Unit=obsidian-push.service
OnCalendar=MON-FRI *-*-* 17:00:00
[Install]
WantedBy=timers.target
EOF
Test the status of obsidian-push.timer
timer
systemctl --user status obsidian-push.timer
Output
obsidian-push.timer - Starts the obsidian-push.service
Loaded: loaded (/home/munmeh/.config/systemd/user/obsidian-push.timer; disabled; vendor preset: enabled)
Active: inactive (dead)
Trigger: n/a
Triggers: ● obsidian-push.service
Service Unit
Create a service which executes the [[obsidian-sync]] bash script to push changes to origin.
Update your obsidian valut path in line below
export OBSIDIAN_LOCAL_PATH="$HOME/Documents/gitrepo/obsidian-personal-vault/"
bash -c "cat >$HOME/.config/systemd/user/obsidian-push.service" <<EOF
#This service unit is for executing obsidian-sync.sh script which in turn push local obsidian changes to git remote
#By Munish Mehta
[Unit]
Description=Push obsidian local vault changes to git remote https://github.com/mumehta/obsidian-personal-vault
Wants=obsidian-push.timer
[Service]
Type=oneshot
ExecStart=/bin/bash -c "$HOME/.obsidian/obsidian-sync.sh $OBSIDIAN_LOCAL_PATH"
[Install]
WantedBy=default.target
EOF
Test status of obsidian-push
service
systemctl --user status obsidian-push.service
Output
● obsidian-push.service - Push obsidian local vault changes to git remote https://github.com/mumehta/obsidian-personal-vault
Loaded: loaded (/home/munmeh/.config/systemd/user/obsidian-push.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Start service and the timer
systemctl --user start obsidian-push.timer
systemctl --user start obsidian-push.service
Check status
service
systemctl --user status obsidian-push.service
Output
obsidian-push.service - Push obsidian local vault changes to git remote https://github.com/mumehta/obsidian-personal-vault
Loaded: loaded (/home/munmeh/.config/systemd/user/obsidian-push.service; disabled; vendor preset: enabled)
Active: inactive (dead) since Thu 2022-09-08 15:22:10 AEST; 1min 27s ago
TriggeredBy: ● obsidian-push.timer
Process: 2873361 ExecStart=/bin/bash -c /home/munmeh/.obsidian/obsidian-sync.sh /home/munmeh/Documents/gitrepo/obsidian-personal-vault/ (code=exi>
Main PID: 2873361 (code=exited, status=0/SUCCESS)
timer
systemctl --user status obsidian-push.timer
Output
obsidian-push.timer - Starts the obsidian-push.service
Loaded: loaded (/home/munmeh/.config/systemd/user/obsidian-push.timer; disabled; vendor preset: enabled)
Active: active (waiting) since Thu 2022-09-08 15:21:55 AEST; 3min 27s ago
Trigger: Thu 2022-09-08 17:00:00 AEST; 1h 34min left
Triggers: ● obsidian-push.service
Sep 08 15:21:55 mmsys systemd[2997]: Started Starts the obsidian-push.service.
Enable timer
and service
units
systemctl --user enable obsidian-push.timer
systemctl --user enable obsidian-push.service
Check logs
journalctl --user -S today -u obsidian-push.timer
journalctl --user -S today -u obsidian-push.service
If you like post, consider buy me a coffee! :coffee:
Reference
This article is part of a series.
- Part 1: Obsidian Sync
- Part 1: Obsidian Sync script
- Part 2: Obsidian Sync as service
comments powered by Disqus