I did write shell script

#echo "Good morning, world."
source activate python36
python /opt/project1/Table_Control.py opt/project1/connection.yaml

After I did write in cron

# job 
1 19 * * * /opt/project1/start.sh

and did try else other variant

# job 
1 19 * * * cd /opt/project1/ && ./start.sh

Did check and got result

May 11 19:01:01 server01 CROND[127428]: (root) CMD (/opt/project1/start.sh)


May 11 19:43:01 server01 CROND[13797]: (root) CMD (cd /opt/project1/ && ./start.sh)

BUT Job must to send me email, has not received any email ((

Did run shell script


work GOOD.

How solve this problem?

  • 1
    python may not be in the the PATH of the environment running the cronjob. Try using the full path for python
    – Lawrence
    May 12, 2018 at 9:37
  • format write Job in cron right? May 12, 2018 at 10:04
  • What do you expect from "source activate python36" ? Do you have a bash script called "activate"? Where? May 12, 2018 at 11:20
  • source activate python36 - this line is not enough? Why it working if run in shell /opt/project1/start.sh? May 12, 2018 at 13:02

3 Answers 3


A common mistake when writing scripts that will be executed later by cron, is that you assume the script will have exactly the same environment that you have when you are logged in and you are developing it. It hasn't!

This answer explains further to check the difference in the process environment and debugging.

However your line source activate python36 assumes that activate is in the current directory, there's also an assumption that python is in the path of the cron task.

Put your command in their own subshell and redirect everything to a logfile to see what's going on.


1 19 * * * (cd /opt/project1/ && ./start.sh) >/tmp/pr1.log 2>&1

Usually to debug such issues it might be handy to add some logging, possible for each line. Like this:

source activate python36 >> /tmp/1.log 2>&1

python opt/project1/Table_Control.py opt/project1/connection.yaml >> /tmp/2.log 2>&1

You can also set cron task to be be laucnhed every minute so that you don't need to wait. Should help.


After change

python opt/project1/Table_Control.py opt/project1/connection.yaml >> /tmp/2.log 2>&1

In log I did find error Python didn't find requests python module.

I did change

python opt/project1/Table_Control.py opt/project1/connection.yaml >> /tmp/2.log 2>&1


/data/Anaconda2-4.4.0/envs/python36/bin/python opt/project1/Table_Control.py opt/project1/connection.yaml >> Table_Control.log >&1


Now did work good, BUT I didn't understand why if I run from shell script - absent errors, BUT if run from cron job did return error didn't find requests python module...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .