DEV Community

Indra Wahyu
Indra Wahyu

Posted on • Updated on

Push Markdown Note File like Obsidian to GitHub using Cronie

I wanted to push my markdown files to github automatically and I solved it with a cron job.

first, I commit my markdown directory and pushed it to github manually, next I created a script to push it automatically. script

#!/usr/bin/env sh

pusher-obsidian=/home/spot/spotspace/pusher-obsidian

cd $pusher-obsidian

git pull origin main -q

result=$(git status --porcelain | wc -l)

if [[ $result -eq 0 ]] ; then
        exit 0

fi
        git add .; git commit -q -m "$(date +"%c")"; git push origin main -q
Enter fullscreen mode Exit fullscreen mode

I use a cron job to run script

crontab -e
Enter fullscreen mode Exit fullscreen mode

and put this

@reboot /bin/sleep 120 ;  <script_directory>
Enter fullscreen mode Exit fullscreen mode

reference

Top comments (0)