MCPcopy Create free account
hub / github.com/cronitorio/cronitor-cli / Save

Method Save

lib/crontab.go:274–293  ·  view source on GitHub ↗
(crontabLines string)

Source from the content-addressed store, hash-verified

272}
273
274func (c *Crontab) Save(crontabLines string) error {
275 if c.IsUserCrontab {
276 cmd := c.buildCrontabCommand("-")
277
278 // crontab will use whatever $EDITOR is set. Temporarily just cat it out.
279 cmd.Env = []string{"EDITOR=/bin/cat"}
280 cmdStdin, _ := cmd.StdinPipe()
281 cmdStdin.Write([]byte(crontabLines))
282 cmdStdin.Close()
283 if output, err := cmd.CombinedOutput(); err != nil {
284 return errors.New("cannot write user crontab: " + err.Error() + " " + string(output))
285 }
286 } else {
287 if ioutil.WriteFile(c.Filename, []byte(crontabLines), 0644) != nil {
288 return errors.New(fmt.Sprintf("cannot write crontab at %s; check permissions and try again", c.Filename))
289 }
290 }
291
292 return nil
293}
294
295func (c Crontab) DisplayName() string {
296 if c.IsUserCrontab {

Callers 7

processCrontabFunction · 0.80
handleGetMonitorsFunction · 0.80
handleDeleteJobFunction · 0.80
handlePostJobFunction · 0.80
handlePostCrontabsFunction · 0.80
handlePutCrontabsFunction · 0.80
handlePutJobFunction · 0.80

Calls 4

buildCrontabCommandMethod · 0.95
CloseMethod · 0.80
ErrorMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected