Python脚本在crontab下不起作用

Joh*_*ith 1 python linux ubuntu cron

我有一个非常基本的python脚本,每分钟运行一次crontab.

剧本

filed = open('test.txt','a')
Run Code Online (Sandbox Code Playgroud)

crontab的

* * * * * /to path the file/job.py
Run Code Online (Sandbox Code Playgroud)

它应该工作,但我无法看到结果.那么,可能是什么问题呢?

Mar*_*ers 6

你需要text.txt使用绝对路径打开; crondaemon可能正在使用与你期望的不同的路径:

filed = open('/home/john/Desktop/test.txt','a')
Run Code Online (Sandbox Code Playgroud)