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 script in CentOS machine.
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()
I restarted my script(systemd) by adding these changes and the script is now running with the job scheduled.
My question is how do I confirm if the job is scheduled from my python script to be run as I configured. I did a cron list as below but couldn't find any listings scheduled.
crontab -u root -l
Also for a test job on interactive shell,
# 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()
How do I see the details of the job id (c4b232a453dd4b5dbea5ef413d7a8c4d) mentioned? Is it possible to look in this way.
Also I looked up another module python-crontab for managing cron jobs. This also didn't list the jobs
>>> from crontab import CronTab
>>> my_cron = CronTab(user='root')
>>> for job in my_cron:
... print job
...