我如何让我的脚本在特定时间重复(python,Ubuntu,Lxde)

问题描述 投票:0回答:2

我正在编写一个脚本,它将更改我的桌面墙纸。这是我当前的脚本:

import os
from time import localtime
from pathlib import Path

wp = Path("/home/lucasmccallums/Desktop/projects/wallpaper_transitions")


hour = localtime().tm_hour

if (hour < 6) or (hour >= 21):
    os.system("pcmanfm --set-wallpaper=" + str(wp / "night.png"))

elif (hour >= 14):
    os.system("pcmanfm --set-wallpaper=" + str(wp / "afternoon.png"))

else:
    os.system("pcmanfm --set-wallpaper=" + str(wp / "morning.png"))

现在,我需要在06:00、14:00和21:00重复该脚本,以便它在一天中自动更改。

任何帮助将不胜感激,谢谢!

python for-loop time ubuntu-16.04 wallpaper
2个回答
0
投票

在Crontab上

0 6,14,21 * * */usr/bin/somedirectory/py.....
© www.soinside.com 2019 - 2024. All rights reserved.