To create a scheduled job that is executed by a Dokku application, follow these steps:

1. Switch into the dokku user and edit the user's crontab:

sudo su
su dokku
crontab -e

2. Add an entry that resembles this one:

0 1 * * * dokku --rm run my-app-name some-command >> /var/log/cron.log 2>&1

Replace the above with your app name, the command that you'd like to run (with your app), and the desired time. When you are done, save the file, and type exit twice to get back to your normal user.

Cron Time Format Reference

The first five columns in a cron table ("crontab") represent specific days and times. See below:

* * * * *
| | | | | 
| | | | |
| | | | +---- Day of the Week   (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month  (range: 1-31)
| +---------- Hour              (range: 0-23)
+------------ Minute            (range: 0-59)

Some examples:

Run at 2am every night:

0 2 * * * 

Run every 5 minutes:

*/5 * * * *

Pro tip: use https://crontab.guru/ to customize your entries.

Troubleshooting

Your cron job will send output to /var/log/cron.log. This is a good starting point.

You can also manually run a one-off command before adding it to cron to ensure it works properly. For example:

dokku --rm run my-app-name some-command