Compare commits
3 Commits
b39ff059be
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| d9ec37a4bd | |||
| e9152da3a9 | |||
| 425b5edbcf |
2
cron.bat
Normal file
2
cron.bat
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
schtasks /Delete /F /TN "InvokeJournal"
|
||||||
|
schtasks /Create /F /TN "InvokeJournal" /TR "C:\Users\Administrator\scoop\shims\InvokeJournal.exe" /SC MINUTE /MO 10 /RL HIGHEST /RU "Administrator"
|
||||||
BIN
crontabd/crontabd.exe
LFS
BIN
crontabd/crontabd.exe
LFS
Binary file not shown.
@@ -103,13 +103,29 @@ func loadCronJobs() error {
|
|||||||
cronExpr := strings.Join(fields[0:5], " ")
|
cronExpr := strings.Join(fields[0:5], " ")
|
||||||
cmdStr := strings.Join(fields[5:], " ")
|
cmdStr := strings.Join(fields[5:], " ")
|
||||||
|
|
||||||
|
cmdStr, err = filepath.Abs(cmdStr)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("Failed to find command: %s", cmdStr)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
cmdStr = filepath.Clean(cmdStr)
|
||||||
|
|
||||||
|
file, err := os.OpenFile(cmdStr, os.O_RDONLY, 0644)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("Failed to find command: %s", cmdStr)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
file.Close()
|
||||||
|
|
||||||
|
logger.Info("Adding cron job: %s -> %s", cronExpr, cmdStr)
|
||||||
|
|
||||||
job := CronJob{
|
job := CronJob{
|
||||||
Cron: cronExpr,
|
Cron: cronExpr,
|
||||||
Command: cmdStr,
|
Command: cmdStr,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the job to cron
|
// Add the job to cron
|
||||||
_, err := cronRunner.AddFunc(job.Cron, createJobFunc(job))
|
_, err = cronRunner.AddFunc(job.Cron, createJobFunc(job))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("Failed to add cron job %+v: %v", job, err)
|
logger.Error("Failed to add cron job %+v: %v", job, err)
|
||||||
continue
|
continue
|
||||||
@@ -124,6 +140,7 @@ func loadCronJobs() error {
|
|||||||
|
|
||||||
func createJobFunc(job CronJob) func() {
|
func createJobFunc(job CronJob) func() {
|
||||||
return func() {
|
return func() {
|
||||||
|
logger.Info("Executing command: %s", job.Command)
|
||||||
cmd := exec.Command(job.Command)
|
cmd := exec.Command(job.Command)
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ nssm set crontabd DisplayName crontabd
|
|||||||
nssm set crontabd AppEnvironmentExtra :PATH='C:\Users\Administrator\scoop\shims'
|
nssm set crontabd AppEnvironmentExtra :PATH='C:\Users\Administrator\scoop\shims'
|
||||||
nssm set crontabd ObjectName LocalSystem
|
nssm set crontabd ObjectName LocalSystem
|
||||||
nssm set crontabd Start SERVICE_AUTO_START
|
nssm set crontabd Start SERVICE_AUTO_START
|
||||||
nssm set crontabd Type SERVICE_WIN32_OWN_PROCESS
|
nssm set crontabd Type SERVICE_INTERACTIVE_PROCESS
|
||||||
nssm set crontabd AppStdout 'C:\Users\Administrator\Seafile\Projects-Go\GoProjects\crontab\crontabd.log'
|
nssm set crontabd AppStdout 'C:\Users\Administrator\Seafile\Projects-Go\GoProjects\crontab\crontabd.log'
|
||||||
nssm set crontabd AppStderr 'C:\Users\Administrator\Seafile\Projects-Go\GoProjects\crontab\crontabd.log'
|
nssm set crontabd AppStderr 'C:\Users\Administrator\Seafile\Projects-Go\GoProjects\crontab\crontabd.log'
|
||||||
Reference in New Issue
Block a user