mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-18 03:01:01 +01:00
bug fix: cron jobs
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
sys.path.append('/usr/local/CyberCP')
|
sys.path.append('/usr/local/CyberCP')
|
||||||
import argparse
|
import argparse
|
||||||
from plogical.processUtilities import ProcessUtilities
|
from plogical.processUtilities import ProcessUtilities
|
||||||
@@ -81,13 +84,33 @@ class CronUtil:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def addNewCron(externalApp, finalCron):
|
def addNewCron(externalApp, finalCron):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||||
cronPath = "/var/spool/cron/" + externalApp
|
cronPath = "/var/spool/cron/" + externalApp
|
||||||
else:
|
else:
|
||||||
cronPath = "/var/spool/cron/crontabs/" + externalApp
|
cronPath = "/var/spool/cron/crontabs/" + externalApp
|
||||||
|
|
||||||
with open(cronPath, "a") as file:
|
from random import randint, seed
|
||||||
file.write(finalCron + "\n")
|
try:
|
||||||
|
seed(time.perf_counter())
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
TempFile = '/tmp/' + str(randint(1000, 9999))
|
||||||
|
|
||||||
|
if os.path.exists(cronPath):
|
||||||
|
FullCrons = open(cronPath, 'r').read()
|
||||||
|
finalCron = '%s%s\n' % (FullCrons, finalCron)
|
||||||
|
with open(TempFile, "w") as file:
|
||||||
|
file.write(finalCron)
|
||||||
|
else:
|
||||||
|
with open(TempFile, "w") as file:
|
||||||
|
file.write(finalCron + '\n')
|
||||||
|
|
||||||
|
command = 'cp %s %s' % (TempFile, cronPath)
|
||||||
|
ProcessUtilities.executioner(command)
|
||||||
|
|
||||||
|
os.read(TempFile)
|
||||||
|
|
||||||
print("1,None")
|
print("1,None")
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
|
|||||||
Reference in New Issue
Block a user