17

I recently set up the Scheduler add on and set up my rake task, 'rake cron_jobs:my_task'.

When I test it with 'heroku run rake cron_jobs:my_task', it works fine.

The scheduler also claims it ran when it was supposed to, and is scheduled to run again, but there's no logging associated with the process the way https://devcenter.heroku.com/articles/scheduler#inspecting-output says there should be.

'heroku ps' shows no scheduled dynos, 'heroku logs --ps scheduler.1' has no output.

What am I missing?

2
  • 5
    Try running just heroku logs --ps scheduler without the '.1' and see if there is any output. Commented Dec 17, 2014 at 19:34
  • In my case I needed to add the app name to the log command: heroku logs --ps scheduler.1 -a myapp. Unfortunately, once the scheduler dyno has finished executing the task, it spins down and I don't think there's a way to inspect its output.
    – DylanReile
    Commented Oct 3, 2017 at 23:05

4 Answers 4

9

Actually I was trying to solve this myself, and did not find the answer anywhere, so here it is if someone else is struggling with this:

heroku logs --tail --ps scheduler

--tail is important to keep streaming the logs.

1

My best guess: the heroku ps and heroku logs commands only give you status logs for currently running processes/dynos.

So after the scheduled rake task is done, you can't reach the logs through the command line.

You can access the history of your logs by using one of the logging addons. Most of them offer a free tier too.

They all are based on the log drains which you also could use directly, if you want to build it yourself.

1

Here is what I do for that:

Simply in your tasks itself include put statements to know when the job started running and when it is finished as well.

Also, you can include puts statement in the executed job as well.

I'm using paper trial add-on which is a very powerful logging tool that you can search and find any particular log at a specific time. Also, you can add an alert when your schedule job started to run.

0

I had a similar problem (using the newer Heroku PGBackups Service) and found an unexpected explanation for it.

The rake task rake pgbackups-archive was not run by Heroku Scheduler, but it worked when I ran it manually from the command line.

In my case, I noticed that my issues were caused by the different time zone used by the Heroku interface (which seems not to be CET). So my rake task which should have run at a specific time daily effectively never ran, as I changed the specific time throughout the day for testing and I always missed the specified time in the Heroku timezone.

You can try running the task every ten minutes and see if it works.

1
  • Heroku recently added the time zone on all timestamps, so this problem should be resolved. Commented Apr 10, 2015 at 16:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.