Category: Database, firewall

With Python there’s always a lot of libraries and options for solving any particular problem and running scheduled or recurring jobs is no exception. Whether you want to run simple deferred task, bunch of scheduled jobs or manage cron tabs, there’s specialized library for that in Python.

One of the use cases for such deferred task can be scheduled shutdown or if you are’re working with network connections or firewall you can create one-time job to revert changes in case you mess up and lock yourself out of the system.

Aside from recurring jobs, you can also use schedule to run one-off tasks and achieve the same effect as with sched, but with nicer syntax: Apart from the deferred job, this code snippet also shows that we need to keep the thread alive for the jobs to run.

The most feature rich and powerful library for scheduling jobs of any kind in Python is definitely APScheduler, which stands for Advanced Python Scheduler.

Related Articles