I am building a Cron job to check leader-slots and during testing/learning phase I saw that the command will not start if the slot isn't greater than first slot of the epoch + stability window slots amount or 1.5 days.

Reading around the web I found out that stability window could be edited by the protocol in some cases (please correct me if I am wrong), and so my question is:

Is there a way to query the first block of the epoch and the current stability window? This way I can check those parameters first and then run leadership-schedule command. Or can you advise other ways to run the leadership-schedule command with a cronjob and being sure that it will run?

Thanks for your time. Have a great day.

EDIT: what I am currently doing is reading gLiveView code and understanding it.

I found out that there is a function called getEpochStart and I could use it with epoch % of completion to find out when run the job, this way I wouldn't need the Stability window slot amount.

From what I understood, the math that I would need to do is:

timestamp = byron_genesis_start_sec(1563999616) + ((epoch_no(197) * BYRON_EPOCH_LENGTH(21600) * BYRON_SLOT_LENGTH(20000)) / 1000)

By doing the math, I got that epoch 197 of Testnet started on timestamp: 1649103616 which sounds odd to me cause it would be at 08:20PM UTC and from what I know, epoch starts at 09:45PM UTC.

Am I missing something?

Edit2: Here's the script that I built after the answer was given to me. I am not an expert on BASH but I does the work, feel free to contact me if you need help with it or have any improvement/suggestions. Link to the script

  • 1
    Your calc looks ok. Testnet started epoch 0 at 2019/07/24 20:20:16 according to explorer.cardano-testnet.iohkdev.io/en/… Mainnet is 2017/09/23 21:44:51 Apr 6, 2022 at 0:43
  • That's exactly what I needed, thanks so much. I'll upload the script once finished in case someone needs it :-) Also if you add your comment to your answer I can mark it as correct
    – Nic_T2H
    Apr 6, 2022 at 6:06

1 Answer 1


You can check the next epoch once the current epoch is 70+% (3.5 days) through, eg:

cardano-cli query leadership-schedule --mainnet ...... --next

You can then:

  1. Use cron and date checking to run this query every 5 days to coincide with being say 75% through the current epoch, or
  2. Check chain/epoch details to determine % through the current epoch and then run the query.

Edit - Added details from comment:

Your calc looks ok.

Testnet started epoch 0 at 2019/07/24 20:20:16 UTC according to https://explorer.cardano-testnet.iohkdev.io/en/browse-epochs.html?page=0&perPage=10

Mainnet started at 2017/09/23 21:44:51 UTC

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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