I have a small bot currently written in php
but i can switch to py
if need be.
It basically gathers data from an api about tasks that need to be ran only once in order to be updated the next day at certain unique times
Each day at UTC+0 00:00
i use a cron job
to gather that data from the api.
For example a task might need to run at UTC+0 09:00
another one at UTC+0 10:15
and another one at UTC+0 11:30
. The next day there are new tasks that need to run at different times.
Now since those tasks are only available for that day i don't think that setting a cron job for each of them at the desired time is a solution and then delete the cron job.
Therefore, how do i run a script just when the task needs to be updated?
For now i'm running a cron job each minute and if there is a task within a minute range i'm running another script that updates that task but that seems messy to me and i'm wondering if i could do something about it.
P.S: I'm using a droplet from digitalocean that runs on Ubuntu 19.04 - disco
To schedule a command to run one time in the future, you can use
at
command. See the manual page (man at
) for how to specify time and date.From php you can use the
system ()
range of commands to call any system command, inclusiveat
. Python also have a system but also a subprocess.run command.