mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-15 17:56:12 +01:00
bug fix: cronjob
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
import os
|
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
|
||||||
|
from random import randint, seed
|
||||||
|
import time
|
||||||
|
try:
|
||||||
|
seed(time.perf_counter())
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
class CronUtil:
|
class CronUtil:
|
||||||
|
|
||||||
@@ -90,27 +94,26 @@ class CronUtil:
|
|||||||
else:
|
else:
|
||||||
cronPath = "/var/spool/cron/crontabs/" + externalApp
|
cronPath = "/var/spool/cron/crontabs/" + externalApp
|
||||||
|
|
||||||
from random import randint, seed
|
print(cronPath)
|
||||||
try:
|
|
||||||
seed(time.perf_counter())
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
TempFile = '/tmp/' + str(randint(1000, 9999))
|
TempFile = '/tmp/' + str(randint(1000, 9999))
|
||||||
|
|
||||||
|
print(TempFile)
|
||||||
|
|
||||||
if os.path.exists(cronPath):
|
if os.path.exists(cronPath):
|
||||||
FullCrons = open(cronPath, 'r').read()
|
FullCrons = open(cronPath, 'r').read()
|
||||||
finalCron = '%s%s\n' % (FullCrons, finalCron)
|
finalCron = '%s%s\n' % (FullCrons, finalCron)
|
||||||
with open(TempFile, "w") as file:
|
with open(TempFile, "w") as file:
|
||||||
file.write(finalCron)
|
file.write(finalCron)
|
||||||
|
print(finalCron)
|
||||||
else:
|
else:
|
||||||
with open(TempFile, "w") as file:
|
with open(TempFile, "w") as file:
|
||||||
file.write(finalCron + '\n')
|
file.write(finalCron + '\n')
|
||||||
|
|
||||||
command = 'cp %s %s' % (TempFile, cronPath)
|
command = 'cp %s %s' % (TempFile, cronPath)
|
||||||
ProcessUtilities.executioner(command)
|
ProcessUtilities.normalExecutioner(command)
|
||||||
|
|
||||||
os.read(TempFile)
|
os.remove(TempFile)
|
||||||
|
|
||||||
print("1,None")
|
print("1,None")
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
|
|||||||
Reference in New Issue
Block a user