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 userroot
, can test logged in to the user in which it was configured?– Rfroes87
On the user it has been set up is working perfectly. The user is
user
. I tested in thecrontab
of that user and viasudo crontab -e
. In both the same situation happens. Initializes Git and does not finish the script. Manually, everything works perfectly.– Virutal Disco
It seems the question How to correctly add 'git push' command to crontab - Ubuntu has a case very similar to yours.
– Rfroes87
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.
– Virutal Disco
If in another Gh account it runs, check the permissions again: usual, SSH key, whatever... as seems to be the case
– egomesbrandao
You are trying to initialize a project, since it already exists.
– Valdeir Psr