chron fix
This commit is contained in:
parent
48b6e22763
commit
001970e7d1
@ -215,9 +215,17 @@ func (s *Scheduler) ScheduleBot(bot *models.Bot) error {
|
||||
}
|
||||
|
||||
// Create the schedule expression
|
||||
// Format: "0 */X * * * *" where X is the interval in minutes
|
||||
// This runs at 0 seconds, every X minutes
|
||||
schedule := fmt.Sprintf("0 */%d * * * *", bot.PostConfig.IntervalMinutes)
|
||||
// For intervals > 60 minutes, we need to use hours
|
||||
var schedule string
|
||||
if bot.PostConfig.IntervalMinutes >= 60 && bot.PostConfig.IntervalMinutes % 60 == 0 {
|
||||
// Format: "0 0 */X * * *" where X is the interval in hours
|
||||
// This runs at 0 seconds, 0 minutes, every X hours
|
||||
schedule = fmt.Sprintf("0 0 */%d * * *", bot.PostConfig.IntervalMinutes/60)
|
||||
} else {
|
||||
// Format: "0 */X * * * *" where X is the interval in minutes
|
||||
// This runs at 0 seconds, every X minutes
|
||||
schedule = fmt.Sprintf("0 */%d * * * *", bot.PostConfig.IntervalMinutes)
|
||||
}
|
||||
|
||||
// Create a job function that captures the bot's information
|
||||
jobFunc := func() {
|
||||
@ -483,7 +491,9 @@ func (s *Scheduler) ScheduleBot(bot *models.Bot) error {
|
||||
s.logger.Info("Bot scheduled successfully",
|
||||
zap.Int64("bot_id", bot.ID),
|
||||
zap.String("name", bot.Name),
|
||||
zap.String("schedule", schedule))
|
||||
zap.String("schedule", schedule),
|
||||
zap.Int("interval_minutes", bot.PostConfig.IntervalMinutes),
|
||||
zap.Int("interval_hours", bot.PostConfig.IntervalMinutes/60))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
BIN
nostr-poster.db-shm
Normal file
BIN
nostr-poster.db-shm
Normal file
Binary file not shown.
BIN
nostr-poster.db-wal
Normal file
BIN
nostr-poster.db-wal
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user