NoobException
NoobException

Reputation: 666

Heroku Scheduler not creating log

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?

Upvotes: 17

Views: 5220

Answers (4)

melsatar
melsatar

Reputation: 61

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.

Upvotes: 1

Kevin Eaverquepedo
Kevin Eaverquepedo

Reputation: 652

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.

Upvotes: 9

Denis Cornehl
Denis Cornehl

Reputation: 4172

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.

Upvotes: 1

a learner has no name
a learner has no name

Reputation: 795

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.

Upvotes: 0

Related Questions