Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron job for git pull

Tags:

cron

I am using crontab to setup cronjob in order to pull from git, manually these commands work but from cronjob the seem not to:

          • cd /var/www/project/ && git pull

How can that be fixed?

like image 754
Przemek Avatar asked Feb 27 '26 01:02

Przemek


1 Answers

It's likely due to sudo permissions required on /var/.

Make a shell script cron_pull.sh anywhere and run it on cron.

In cron_pull.sh:

#!/bin/bash
cd /var/www/project
git pull

Run

sudo chmod +x cron_pull.sh

In sudo crontab -e:

* * * * * /path/to/cron_pull.sh
like image 118
Jim Avatar answered Mar 02 '26 16:03

Jim