- #1
- 2,153
- 2,719
My distro is Ubuntu 22.04.2 LTS. I am trying to set up a
The script works fine when I run it from the terminal.
The cron job is set up as follows:
This throws the following error, that I can retrieve via
This answer on Serverfault suggested that I should put the path explicitly. I did that. It threw the same error again.
Note that I am accessing
Any idea how I can set this up?
cron
job that will clone a private GitHub repo via git every hour, run lualatex
, and save the compiled PDF to Google Drive. I have written a script for this purpose:
myscript.sh:
#!/bin/bash
cd /home/wrichik-basu/opt/cron_scripts
if [ ! -d "./temp" ]; then
mkdir temp
fi
cd temp
if [ -d "./myrepo" ]; then
rm -rdf ./myrepo
fi
echo "Cloning repo..."
git clone -q --depth=1 <SSH_Link_to_private_GitHub_repo>
cd myrepo
echo "Running LuaLaTeX #1..."
lualatex -interaction=nonstopmode formulae_main.tex >/dev/null
status=$?
if [ $status -eq 0 ]; then
echo "Running LuaLaTeX #2..."
lualatex -interaction=nonstopmode formulae_main.tex >/dev/null
status=$?
if [ $status -eq 0 ]; then
echo "Copying generated PDF to Google Drive..."
cp ./main.pdf /path/to/Google/Drive/mount
fi
fi
echo "Cleaning up..."
cd ../..
rm -rdf ./temp
The script works fine when I run it from the terminal.
The cron job is set up as follows:
Bash:
10 */1 * * * /full/path/to/script/myscript.sh >/dev/null
This throws the following error, that I can retrieve via
postfix
:
Error:
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/wrichik-basu>
X-Cron-Env: <LOGNAME=wrichik-basu>
Message-Id: <redacted>
Date: Wed, 7 Jun 2023 11:10:03 +0530 (IST)
Status: R
X-IMAPbase: 1686118612 3
X-UID: 1
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
/full/path/to/script/myscript.sh: line 18: cd: myrepo: No such file or directory
/full/path/to/script/myscript.sh: line 21: lualatex: command not found
This answer on Serverfault suggested that I should put the path explicitly. I did that. It threw the same error again.
Note that I am accessing
crontab
via crontab -e
or crontab -l
, i.e. not as sudo
.Any idea how I can set this up?
Last edited: