0

This is how I configure crontab (by using crontab -e)

* * * * * /home/jeff/Desktop/scripts/job_pull_queue.sh >> /home/jeff/Desktop/scripts/log.txt

This is the content of /home/jeff/Desktop/scripts/job_pull_queue.sh

#!/bin/bash
echo "Running job_pull_queue.sh @ $(date)"
cd /home/jeff/Documents/code/some_project
echo $(printenv)
/home/jeff/miniconda3/bin/python -m util.main

Now the problem is, when running ./job_pull_queue.sh in the terminal, it works, but I can tell from the log file that crontab never executes that last line /home/jeff/miniconda3/bin/python -m util.main (I can see the result from the previous echo in the log file, but not the python script itself), what happened? How do I fix it?

Update: here's the result from printenv when ran by crontab

SHELL=/bin/sh PWD=/home/jeff/Documents/code/some_project LOGNAME=jeff HOME=/home/jeff LANG=en_US.UTF-8 SHLVL=0 PATH=/usr/bin:/bin OLDPWD=/home/jeff _=/usr/bin/printenv

1 Answer 1

1

Ok...

My Python script reads several env variables from my user profile, and of course, these variables don't exist when crontab is running the script...

And I don't have detection/logging in place so I didn't know env variables are missing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.