ku1ik / git-dude

Git commit notifier

Home Page:http://ku1ik.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running as daemon through cron (Ubuntu 15.10)

anobilisgorse opened this issue · comments

Hello. I tried adding this to my cron script so I can daemonize this git-dude:

@reboot /home/zero/.bin/git-dude 'Documents/2015-2016/Second\ Semester/CSC\ 199/Source\ Code/'

Where /home/zero/.bin/git-dude is the location of where I stored the git-dude script and the location after it is the directory with a local repo that I want to watch/observe.

Except that it doesn't work as it is supposed to do (at startup). I tried figuring it out where the fault might be, by manually calling the command in the terminal:
1.) For @reboot, it works perfectly fine with a simple echo "hi" > /home/zero/reboot.txt 2>&1 (which creates a .txt file in my Home dir)
2.) Calling the script by its location /home/zero/.bin/git-dude ..... instead of just git dude ...... Works perfectly fine with this and other test repos.
3.) Enclosing the location of the repo with quotation marks/apostrophes ' '. It works with or without.

So I was wondering where the issue might be, and why it doesn't work in cron but works if the git dude command is triggered manually.

PS. Also, any other forms of daemonizing this git dude aside from cron will be very appreciated.
Thanks in advance.

Hi @anobilisgorse!

Guess I'd share my way of approaching it.

Instead of creating a crontab job for this particular thing, which runs as soon as cron daemon starts. But especially when I don't want my little thing running when I'm not logged on, so I did it with a "startup application" in Ubuntu instead.

I've created ~/.git-dude/bin where I've put a simple script containing following

#!/bin/bash
#
# run-gd - Simple script to run git-dude on ubuntu login
#

watchdir=$(git config dude.watchdir)

if [ -n $watchdir ]; then
    git dude $watchdir  
fi

Then after that, I've added a "custom" startup application pointing to that script, which is started when I'm logging in.

I like @holmboe's suggestion to run it as a service instead as a cron job 👍

@sickill thanks but the props goes to my brother @rholmboe :)

@holmboe haha, you're right 🙈

@sickill it's ok, I take credit for everything @holmboe does anyways, so he can have this one 💃