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

  • 1
    Take a look at the at command. With at you can schedule a job to run once at a specific time in the future.
    – Soren A
    Jul 12, 2019 at 8:29
  • Oh, was it that easy? X_X Can i run this command using php/py?
    – emma
    Jul 12, 2019 at 8:32
  • 1
    Both languages should have some kind of system () call .. for php i googled php execute shell command and got this as first hit: binarytides.com/execute-shell-commands-php
    – Soren A
    Jul 12, 2019 at 8:52
  • You should add your comment/s as an answer :P so i can mark it as preferred.
    – emma
    Jul 12, 2019 at 8:58

1 Answer 1


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, inclusive at. Python also have a system but also a subprocess.run command.

  • Saved me a ton of headaches. Thanks! :D
    – emma
    Jul 12, 2019 at 9:20
  • i really have some problems in using php to run this command cause i can't run it in one line O_O can you help me? Or should i open a question about this? :-?
    – emma
    Jul 12, 2019 at 9:40
  • @emma .. I thing you should open a new question with an example of your code .. you already did, I see ;-)
    – Soren A
    Jul 12, 2019 at 10:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .