简体   繁体   English

无法在腻子的 Cron Job 中运行 python 文件

[英]Not able to run python file in Cron Job in putty

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我正在使用 Putty,它没有 Python3 它有 python2 或 python 所以尝试使用命令运行 python 文件

 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.我使用 spark2-submit 命令运行的 python 文件完全正常。 This is a pyspark file converted to python.这是一个转换为 python 的 pyspark 文件。 When I use /usr/bin/python2 I get error for line "from pyspark.sql import sparksession" - error-> No module named pyspark.sql.当我使用 /usr/bin/python2 时,“从 pyspark.sql 导入 sparksession”行出现错误 - 错误 -> 没有名为 pyspark.sql 的模块。

I think spark2-submit is not supported in corntab job.我认为corntab作业不支持spark2-submit。 and /usr/bin/python2 is giving error for pyspark convered python file.并且 /usr/bin/python2 为 pyspark 转换的 python 文件提供错误。

Can anyone please help me out here.任何人都可以在这里帮助我。

Cronjob commands should contain minute(m), hour(h), day of month(dom), month(mon) and day of week(dow). Cronjob 命令应包含分钟(m)、小时(h)、月份(dom)、月份(mon)和星期(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 :例如,如果你想在每天 08:55 运行你的代码,你可以使用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM