I have several Git repositories with LaTeX files that I want to have typeset automatically. The idea is to have a central bash script (run by a cronjob) that executes a bash script in every repository, which (1) pulls new commits and (2) executes make all
, which should call latexmk
on the changed LaTeX files.
The central bash script simply contains lines like:
bash ./repos/repo-xyx/cron.sh
Then in repos/repo-xyz/cron.sh
is something like:
cd "$(dirname "$0")"
git pull
make all
cd -
And in the Makefile in the same directory:
all: $(subst .tex,.pdf,$(wildcard *.tex))
%.pdf: %.tex
latexmk -pdf -pdflatex="pdflatex -shell-escape" $< </dev/null
In my user's crontab, I have * * * * * bash .../cron.sh 2>&1 > .../cron.log
and SHELL=/bin/bash
.
When the cronjob is executed, I read the following in the log:
Already up-to-date.
latexmk -pdf -pdflatex="pdflatex -shell-escape" myfile.tex </dev/null
.../ (this comes from the line "cd -")
As you can see, latexmk
is invocated but doesn't do anything. myfile.pdf
is not generated.
When I run bash cron.sh
(as the same user) from the highest directory, this does work.
What could cause the Makefile to not execute commands when run from a bash script that is run by a cron job (at least, I think it's make not executing this command)?
This is GNU Make 3.81 on Linux ubuntu 3.13.0-51-generic #84-Ubuntu SMP Wed Apr 15 12:08:34 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
.