I am using the Advanced Python Scheduler module in my scripts to schedule a job for every last day of the month. I am running this python script as a
systemd
from apscheduler.schedulers.blocking import BlockingScheduler
if __name__ == '__main__':
sched = BlockingScheduler()
sched.add_job(lambda: my_aggregation_function(url_list, 'monthly'), 'cron', day='last')
while True:
sched.start()
crontab -u root -l
# python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from apscheduler.schedulers.blocking import BlockingScheduler
>>> sched = BlockingScheduler()
>>> def job_function():
... print "Hello World"
...
>>> sched.add_job(job_function, 'cron', day='last')
<Job (id=c4b232a453dd4b5dbea5ef413d7a8c4d name=job_function)>
>>> sched.start()
c4b232a453dd4b5dbea5ef413d7a8c4d
cron
>>> from crontab import CronTab
>>> my_cron = CronTab(user='root')
>>> for job in my_cron:
... print job
...
I think there's a grave misunderstanding here. It seems you think APScheduler is somehow managing the system's cron jobs. It is not. It's an in-process scheduler which just happens to have a cron-like trigger for scheduling the jobs. APScheduler has no connection whatsoever to any cron daemon or crontabs.
Updating the actual answer from the comments. The API is defined in the apscheduler
official documentation
scheduler.get_jobs()