我使用下面的python代码来调度ubuntu中的作业。在
from crontab import CronTab
cron = CronTab(user='username')
job = cron.new(command='/usr/bin/python3 /home/(user)/Desktop/Schedular/ScheduleInvoicingUtility.py >> /home/(user)/Desktop/Schedular/Logs.txt')
job.setall('*/2 * * * *')
cron.write()
print(cron.render())
代码运行成功,其呈现函数print输出如下:
^{pr2}$但不知道这个作业保存在ubuntu中的什么地方,而且作业在指定的时间后没有运行/工作。在
你知道我做错什么了吗?在
最后,我用一些小的改动来解决这个问题。下面是从python正确创建cron作业的代码:
使用此选项可删除以前具有相同id的作业
^{pr2}$完整代码为:
^{3}$别忘了导入CronTab:
使用pip安装python_crontab。在
相关问题 更多 >
编程相关推荐