Python中文
首页
教程
问答
标签
搜索
登录
注册
在Ubuntu16.04上,如何使用crontab重复运行python脚本
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我想在ubuntu16.04上使用crontab反复运行python脚本</p> <p>我在终端上运行下面的命令。你知道吗</p> <pre><code>$crontab -e </code></pre> <p>并在上面写了如下。你知道吗</p> <pre><code>1 * * * * python /home/elite/python/weather.py </code></pre> <p>我认为,这确实意味着每分钟都要运行<code>weather.py</code>脚本。你知道吗</p> <p>这是用于测试<code>crontab</code>功能的<code>weather.py</code>脚本。你知道吗</p> <pre><code>from urllib import urlopen import time import re testing = 'testing' current_time = time.localtime() today = time.strftime('%Y-%m-%-d-%-s', current_time) file_name = today + ".txt" output = open("/home/elite/python/" + file_name, "w") output.write(testing) </code></pre> <p>当我在终端上运行这个脚本-<code>$python weather.py</code>时,它运行得很好。你知道吗</p> <p>但是<code>crontab</code>似乎不起作用。你知道吗</p> <p>我怎么处理?你知道吗</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>开头的1表示一小时中的一分钟,所以它应该每小时运行一次,而不是每分钟。你知道吗</p> <p>如果你想每分钟都跑,你需要<code>* * * * *</code></p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
jupyter运行一个旧的pytorch版本
9 回答
Jupyter运行不同版本的卸载库?
10 回答
Jupyter运行指定的键盘快捷键
6 回答
Jupyter通过.local文件“逃逸”virtualenv。我该如何缓解这种情况?
3 回答
Jupyter重新加载自定义样式
10 回答
Jupyter错误:“没有名为Jupyter_core.paths的模块”
5 回答
jupyter错误:无法在随机林中将决策树视为png
2 回答
Jupyter错误'内核似乎已经死亡,它将自动重新启动'为一个给定的代码块
1 回答
Jupyter错误地用阿拉伯语和字母数字元素显示Python列表
9 回答
Jupyter隐藏数据帧索引,但保留原始样式
10 回答
Jupyter集线器:启动器中出现致命错误。。。系统找不到指定的文件
4 回答
Jupyther中相同值的相同哈希,但导出到Bigquery时不相同
4 回答
Jupy上Python的读/写访问问题
7 回答
jupy上没有模块cv
5 回答
Jupy上的排序错误
1 回答
Jupy中bqplot图形的紧凑布局
9 回答
Jupy中matplotlib plot的连续更新
10 回答
Jupy中Numpy函数的文档
1 回答
Jupy中Pandas的自动完成问题
9 回答
jupy中Qt后端的Matplotlib动画
1 回答