bug fix: cron path for ubuntu

This commit is contained in:
Usman Nasir
2020-02-11 21:33:20 +05:00
parent d7b766cd82
commit 0d54457db1
2 changed files with 11 additions and 5 deletions

View File

@@ -77,9 +77,12 @@ class CronUtil:
@staticmethod @staticmethod
def addNewCron(externalApp, finalCron): def addNewCron(externalApp, finalCron):
try: try:
CronPath = '/var/spool/cron/%s' % (externalApp) if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
cronPath = "/var/spool/cron/" + externalApp
else:
cronPath = "/var/spool/cron/crontabs/" + externalApp
with open(CronPath, "a") as file: with open(cronPath, "a") as file:
file.write(finalCron + "\n") file.write(finalCron + "\n")
print("1,None") print("1,None")

View File

@@ -1548,11 +1548,14 @@ class WebsiteManager:
website = Websites.objects.get(domain=self.domain) website = Websites.objects.get(domain=self.domain)
CronPath = '/var/spool/cron/%s' % (website.externalApp) if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
cronPath = "/var/spool/cron/" + website.externalApp
else:
cronPath = "/var/spool/cron/crontabs/" + website.externalApp
commandT = 'touch %s' % (CronPath) commandT = 'touch %s' % (cronPath)
ProcessUtilities.executioner(commandT, 'root') ProcessUtilities.executioner(commandT, 'root')
commandT = 'chown %s:%s %s' % (website.externalApp, website.externalApp, CronPath) commandT = 'chown %s:%s %s' % (website.externalApp, website.externalApp, cronPath)
ProcessUtilities.executioner(commandT, 'root') ProcessUtilities.executioner(commandT, 'root')
CronUtil.CronPrem(1) CronUtil.CronPrem(1)