簡體   English   中英

具有文件訪問權限時,為python執行cron作業失敗

[英]Executing cron job for python fail when it has file acess

我想每 10 分鍾執行一次我的 python 文件。 我正在使用 ubuntu 實例。 此語句在文件訪問行之前不起作用。 我無法弄清楚問題所在。 我已經將這個測試到 /usr/bin/ pythonpython3python3.6

   */10 * * * * /usr/bin/python /home/ubuntu/Deploy/sam.py >> /home/ubuntu/test.log

文件訪問不起作用。 如何給文件訪問權限?

文件

print('HI')
with open("EsText.txt", "a") as myfile:
    myfile.write("kugan")
    myfile.close()

你的 cron 表達式應該是0 0/10 * 1/1 * ? * 0 0/10 * 1/1 * ? *你可以從這里得到幫助

也可以嘗試使用>而不是>>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM