Cannot run a python script using crontab

NKB

I am struggling to run the a python script as a cron job.

I am logged in as root the permission for the python script is

-rwxr-xr-x 1 root root 2374 Mar  1 22:49 k_collab_spark.2.py

I am starting the script with

#!/usr/bin/env python

I tested the pythong script if i do "./k_collab_spark.2.py` this work fine.

on the crontab i have set the job as

15 12 * * * /opt/lampp/htdocs/testme/SPARK/k_collab_spark.2.py >> /var/log/kspark.log

I do not see any message on the log file

Once i adde 2>&1 it gives an error Traceback (most recent call last): File "/opt/lampp/htdocs/kabeer/SPARK/k_collab_spark.2.py", line 2, in import requests ImportError: No module named requests but if i execute the service manually it is successful . WHen i run it manually it works fine

Tried defining the path but still the same issue

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin import requests ImportError: No module named requests

Any idea what i am missing.. Appreciate any help around this.

NKB

I used a shell script to call the python script. THe anaconda on the box was causing the trouble

export PATH=/opt/anaconda3/bin:$PATH /opt/anaconda3/bin/python /opt/lampp/htdocs/scriptme.py >/opt/lampp/htdocs/scriptme.log 2>&1

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related