# backup current cron jobs to tmp file
task="/path/to/some/task"
timing="0 0 * * *"
tmpCron=$(mktemp)
crontab -l > "$tmpCron"

# check if update repo already exists in current cron
if grep "$task" "$tmpCron" 1>/dev/null
then
	echo "$task cron task, already exists, leaving cron unchanged"
else
    # append tasks to cron
    echo "$timing $task" >> "$tmpCron"
    
    # update cron
    crontab "$tmpCron" || { echo "failed to update cron, exiting..."; exit 1; }
fi

# delete tmp file
rm "$tmpCron"