Andrew
Andrew

Reputation: 4441

Crontab job to run a bash alias every 5 minutes

I've been trying to do this through a .php script, running the file locally works, but not through cron or through apache. I could leave it in .php, but don't really need it in .php.

The PHP file in the folder location that I want this ran in (git repro off of that folder)

crontab -l:

*/5 * * * * /usr/bin/php /var/www/website/test.php

PHP:

<?
exec('cd /var/www/website && git pull origin master',$outputArray);
print_r($outputArray);
?>

I have a bash alias that has this command in it, but I don't know how to get crontab to run that.

The goal is to have this box auto update to the latest git commit every 5 minutes. I may be approaching this 100% incorrectly. SSHing into the box to execute this is not perferred.

Upvotes: 1

Views: 1149

Answers (1)

Dominic Rodger
Dominic Rodger

Reputation: 99761

You're right, doing that in PHP is unnecessary. I think you just want a line like this in your crontab:

*/5 * * * * cd /var/www/website && git pull origin master > /place/to/put/logs/mycommand.log

Upvotes: 2

Related Questions