-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cron job for relayer flush (#954)
- Loading branch information
1 parent
d3c1705
commit 24d39dd
Showing
2 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cronjobs | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"strings" | ||
) | ||
|
||
func Add(schedule, command string) error { | ||
cronEntry := fmt.Sprintf("%s %s\n", schedule, command) | ||
|
||
getCurrentCmd := exec.Command("crontab", "-l") | ||
currentCrontab, err := getCurrentCmd.Output() | ||
if err != nil { | ||
currentCrontab = []byte{} | ||
} | ||
|
||
newCrontab := string(currentCrontab) + cronEntry | ||
|
||
setCrontabCmd := exec.Command("crontab", "-") | ||
setCrontabCmd.Stdin = strings.NewReader(newCrontab) | ||
return setCrontabCmd.Run() | ||
} |