Problems with crontab and Git push script

Asked

Viewed 38 times

1

I created a scrip . sh to update my repository in Git Hub. Manually the scrip runs perfectly.

#!/bin/bash

cd /home/user/tmp/
git init
git add .
git commit -m "`date +'%Y_%m_%d'`"
git push --force origin main

crontab runs and generates a log called cronlog.txt. Log content is:

Reinitialized existing Git repository in /home/user/tmp/.git/

That is, cron runs the script in part, but not in full.

I am grateful for any aid

  • In which crontab is the execution of your script scheduled? If not with the user root, can test logged in to the user in which it was configured?

  • On the user it has been set up is working perfectly. The user is user. I tested in the crontab of that user and via sudo crontab -e. In both the same situation happens. Initializes Git and does not finish the script. Manually, everything works perfectly.

  • It seems the question How to correctly add 'git push' command to crontab - Ubuntu has a case very similar to yours.

  • Yes, I’ve tried the solution they proposed and it didn’t work. On another server it runs all correctly, on another Git Hub account, of course.

  • If in another Gh account it runs, check the permissions again: usual, SSH key, whatever... as seems to be the case

  • You are trying to initialize a project, since it already exists.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.