user2901: 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

user6632: 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:

Use cron and date checking to run this query every 5 days to coincide with being say 75% through the current epoch, or
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

2901: <p>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.</p>
<p>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:</p>
<p>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?</p>
<p>Thanks for your time. Have a great day.</p>
<p><strong>EDIT:</strong>
what I am currently doing is reading gLiveView code and understanding it.</p>
<p>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.</p>
<p>From what I understood, the math that I would need to do is:</p>
<pre><code>timestamp = byron_genesis_start_sec(1563999616) + ((epoch_no(197) * BYRON_EPOCH_LENGTH(21600) * BYRON_SLOT_LENGTH(20000)) / 1000)
</code></pre>
<p>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.</p>
<p>Am I missing something?</p>
<p><strong>Edit2:</strong>
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.
<a href="https://github.com/Techs2Help/leaderScheduleCheck_cron" rel="nofollow noreferrer">Link to the script</a></p>
 6632: <p>You can check the <code>next</code> epoch once the current epoch is 70+% (3.5 days) through, eg:</p>
<p><code>cardano-cli query leadership-schedule --mainnet ...... --next</code></p>
<p>You can then:</p>
<ol>
<li>Use cron and date checking to run this query every 5 days to coincide with being say 75% through the current epoch, or</li>
<li>Check chain/epoch details to determine % through the current epoch and then run the query.</li>
</ol>
<p><strong>Edit</strong> - Added details from comment:</p>
<p>Your calc looks ok.</p>
<p>Testnet started epoch 0 at 2019/07/24 20:20:16 UTC according to <a href="https://explorer.cardano-testnet.iohkdev.io/en/browse-epochs.html?page=0&amp;perPage=10" rel="nofollow noreferrer">https://explorer.cardano-testnet.iohkdev.io/en/browse-epochs.html?page=0&amp;perPage=10</a></p>
<p>Mainnet started at 2017/09/23 21:44:51 UTC</p>
