Python cronjob无法运行

编程入门 行业动态 更新时间:2024-10-26 04:24:52
本文介绍了Python cronjob无法运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我通过SSH进入我的Ubuntu 6.4 VM并运行 python nomi.py 时,我的脚本将按预期执行。

When I am SSH'd into my Ubuntu 6.4 VM and run python nomi.py, my script executes as it should.

我如下设置我的crontab文件,以便每15分钟运行一次脚本:

I set up my crontab file as follows in order to run the script every 15 mins:

# m h dom mon dow command */15 * * * * /usr/bin/python home/cron1admin/nomi.py

我设置crontab文件的方式有什么问题吗?创建crontab文件后,我需要做任何事情吗?

Is there anything wrong with how I set up the crontab file? Do I need to do anything after the crontab file is created?

nomi.py 文件将数据发送到Google分析,当我运行脚本时,数据就会通过。当我尝试让cron作业运行脚本时,什么也没发生。

The nomi.py file sends data to Google Analytics, and when I run the script, the data goes through. When I attempt to let the cron job run the script, nothing happens.

ps aux | grep cron表

ps aux | grep cron table

root 1029 0.0 0.0 19120 932 ? Ss Jun26 0:01 cron root 5896 0.0 0.3 73448 3724 ? Ss 16:41 0:00 sshd: cron1admin [priv] 1000 6084 0.0 0.1 73448 1656 ? S 16:42 0:00 sshd: cron1admin@pts/0 root 6745 0.0 0.3 73448 3628 ? Ss 18:07 0:00 sshd: cron1admin [priv] 1000 6926 0.0 0.1 73448 1552 ? S 18:07 0:00 sshd: cron1admin@pts/1 1000 7065 0.0 0.0 9392 944 pts/1 S+ 18:21 0:00 grep --color=auto cron

推荐答案

以下问题建议您使用绝对路径,而不要依赖〜扩展到主目录。

The following question suggests that you should use absolute paths instead of relying on ~ to expand to your home directory.

还要确保 cron 实际上正在运行。您可以通过grepping cron 进程来做到这一点。在Ubuntu Linux上,我通常使用以下命令。

Also make sure cron is actually running. You can do this by grepping for the cron process. On Ubuntu Linux, I usually use the following command.

ps aux | grep cron

更多推荐

Python cronjob无法运行

本文发布于:2023-07-16 04:08:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117688.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Python   cronjob

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!