Not able to run python file in Cron Job in putty

Viewed 23

I am using Putty and it does not have Python3 it has python2 or python so tried both to run python file by using command

 55 08 * * * /usr/bin/python2  /home/user/file.py

and couple of other commands BUT nothing is working.

The python file I have runs totally fine with spark2-submit command. This is a pyspark file converted to python. When I use /usr/bin/python2 I get error for line "from pyspark.sql import sparksession" - error-> No module named pyspark.sql.

I think spark2-submit is not supported in corntab job. and /usr/bin/python2 is giving error for pyspark convered python file.

Can anyone please help me out here.

1 Answers

Cronjob commands should contain minute(m), hour(h), day of month(dom), month(mon) and day of week(dow).

You should write them using the format below :

# (m) (h) (dom) (mon) (dow)  command

You're missing one parameter in your case.

For example, if you want to run your code at 08:55 everyday, you can use :

55 08 * * * /usr/bin/python2  /home/user/file.py
Related