【问题标题】:ubuntu : Schedule python scripts using Forkubuntu : 使用 Fork 调度 python 脚本
【发布时间】:2025-12-18 13:50:02
【问题描述】:

我正在尝试在 Ubuntu 16.04 中使用 fork() 在某个预定时间执行 python 脚本。在阅读文档时,我没有遇到 fork() 中的调度选项。

fork() 是否有调度选项?

目前,我正在使用 `CRON' 调用 python 脚本,但似乎 CRON 作业的优先级总是最低。

在执行大量数据库操作的 Ubuntu 中安排每日操作的最佳选择是什么?

【问题讨论】:

    标签: python linux ubuntu cron fork


    【解决方案1】:

    Advanced Python Scheduler 可以提供帮助:http://apscheduler.readthedocs.io/en/latest/

    这是一个使用它的示例代码:

    from apscheduler.schedulers.blocking import BlockingScheduler
    
    def some_job():
        print "Decorated job"
    
    scheduler = BlockingScheduler()
    scheduler.add_job(some_job, 'interval', hours=1) 
    scheduler.start()
    

    【讨论】:

    • 感谢您的回复。您有关于fork 的任何信息吗?是否有任何调度功能