Today I’d like to share a note on how to be confident that the new cron job is configured properly and is added to crontab.
I usually use whenever to configure cron jobs.
Assuming that the deployment is set up properly, we will only need to check that
the cron job is added to whenever’s
Here’s an example. Consider we want to clean up our database monthly on 1st of ‘Month’. It doesn’t matter what “clean up” means here. Let it be “delete old unpaid orders” or “delete draft posts made by anonymous users”
We’ve just wrote our task with test.
Let’s ensure we will run it at a right time, because we don’t need to run it often:
Here we capture output of a part of crontab file generated by
search for a line with our task and check that it configured properly.
This test will fail if you don’t add a task to