Script for GIT update

Asked

Viewed 324 times

1

I have a question and I don’t know how to fix it. The following happens, I created a script in sh called atualiza.sh inside it I have the following code.

git add .
git commit -m"atualiza rotina"
git push
xxxxxxxxxxx

My goal is to run a routine every day that automatically updates any change in git and sends it to my versioning server. Only when routine runs this file sh that I created nothing happens. Can anyone tell me what the mistake is?

  • Have a log? Maybe that’s the way to find out. Or maybe adding > log.txt at the end of the command, you find out what is wrong.

  • Returns nothing in the log :(

  • If in fact the above commands are in the script, something should appear. Is there a chunk of the script before what you posted? What command are you using to run the script?

  • Your.sh file is inside the project directory?

1 answer

1


Try the following

Create a script like this

#!/bin/bash

cd /home/{user}/localDoScript/atualiza.sh 
/usr/bin/git add -A 
/usr/bin/git commit -am "Atualiza rotina`date`"
/usr/bin/git push

In cron add it to run daily at the desired time

* 22 * * * cd /home/{user}/localDoScript/ && ./atualiza.sh

in this case every day at 22hrs

  • 1

    It worked out, thanks!

Browser other questions tagged

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