0

I have a python script called git_update.py to git pull a repository and I want to schedule this to run everyday at 6 AM. but the below code doesnnot work

git_update.py

import os
import schedule
import logging
import subprocess

def git_update():
    out = subprocess.check_output(["git", "pull"])

if __name__ == '__main__':
    schedule.every().day.at("06:00").do(git_update)

And I reason I think it doesn't work because it always asks for my password whenever I pull a repository. Is there any way I can have the password saved when I first launch the script using nohup git_update.py &

Shanoo
  • 1,185
  • 1
  • 11
  • 38
  • 1
    This is not really related to Python; the same thing would happen with basic shell script. The `cron` daemon has no access to your `ssh` secrets, if indeed the SSH agent is even running when the job starts. – tripleee Nov 18 '20 at 17:59
  • @tripleee Can do point me to the link to the shell script that does the same? – Shanoo Nov 18 '20 at 18:03
  • 1
    The "script" to do this in shell is just `git pull`. Regarding management of secrets, see https://stackoverflow.com/questions/2205282/ssh-agent-and-crontab-is-there-a-good-way-to-get-these-to-meet but I'm obviously guessing what you are actually hoping to accomplish here. – tripleee Nov 18 '20 at 18:05
  • https://stackoverflow.com/search?q=%5Bgit%5D+save+password – phd Nov 18 '20 at 18:16

0 Answers0