summaryrefslogtreecommitdiff
path: root/postgresqleu/scheduler/util.py
diff options
context:
space:
mode:
authorMagnus Hagander2019-09-28 18:21:51 +0000
committerMagnus Hagander2019-09-30 14:16:01 +0000
commiteb4de04bad88147db848e8770371b9c6bb1ff64b (patch)
tree55cef45f6ff0f38e5843c287ead8f9de666b2087 /postgresqleu/scheduler/util.py
parentd351641975f39522499e07958c66ab3c037e16e7 (diff)
Add function to trigger immediate run of a scheduled job
Diffstat (limited to 'postgresqleu/scheduler/util.py')
-rw-r--r--postgresqleu/scheduler/util.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/postgresqleu/scheduler/util.py b/postgresqleu/scheduler/util.py
index 40c23d23..526fabe5 100644
--- a/postgresqleu/scheduler/util.py
+++ b/postgresqleu/scheduler/util.py
@@ -8,6 +8,15 @@ def notify_job_change():
curs.execute("NOTIFY pgeu_scheduled_job")
+def trigger_immediate_job_run(command):
+ from .models import ScheduledJob
+
+ j = ScheduledJob.objects.get(command=command)
+ j.nextrun = datetime.now()
+ j.save(update_fields=['nextrun'])
+ notify_job_change()
+
+
def _get_next_time(times):
# Next time will be the first one that's after current time
current = datetime.now().time()