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

Method buildCrontabCommand

lib/crontab.go:930–942  ·  view source on GitHub ↗

buildCrontabCommand builds a crontab command with appropriate user flag if needed

(args ...string)

Source from the content-addressed store, hash-verified

928
929// buildCrontabCommand builds a crontab command with appropriate user flag if needed
930func (c Crontab) buildCrontabCommand(args ...string) *exec.Cmd {
931 if c.User != "" {
932 // Check if we need to add -u flag (when accessing another user's crontab)
933 if currentUser, err := user.Current(); err == nil && currentUser.Username != c.User {
934 // Insert -u flag and username before other arguments
935 cmdArgs := []string{"-u", c.User}
936 cmdArgs = append(cmdArgs, args...)
937 return exec.Command("crontab", cmdArgs...)
938 }
939 }
940 // Default case: run crontab command without -u flag (for current user)
941 return exec.Command("crontab", args...)
942}

Callers 3

SaveMethod · 0.95
ExistsMethod · 0.95
loadMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected