Pregunta

Background

I launched several jobs using the Advanced Python Scheduler (APScheduler) using code similar to the one below.

sched = Scheduler()
sched.start()
sched.add_interval_job(function, minutes=1)
sleep(10000)
sched.shutdown()

I did this from the terminal.

python script.py

Problem

I intended for the jobs to be run a large number of times before shutting down. Unfortunately, I accidentally closed the terminal during their sleep stages, before the jobs could be stopped appropriately with sched.shutdown().

I believe the jobs are still running in the background as I have evidence that the function has been applied even after the terminals were closed.

Question

Is there any way to identify which jobs are still running somewhere in the background and shut them down? Thank you in advance!

¿Fue útil?

Solución

Find the process id and kill the process using kill <PID>, or simply pkill -f script.py.

Otros consejos

If you run your script like:

python scrip.py

after you close the terminal, python process will be killed, so your script stop running.

But if you run your script with &

python scrip.py &

process will be not killed after terminal close, and you can check it using

ps -e | grep python

You have to understand different between jobs and system process. Closing the terminal kills the process. If you want check which jobs are still working, you can use print_jobs() function.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top