<commit_before>from crontab import *
from ee.core.logging import Log

"""
Set CRON on LINUX system.
"""

class EECron():
    def setcron_daily(self,cmd,comment='Cron set by EasyEngine',user='root',min=0,hour=12):
        tab = CronTab(user=user)
        cron_job = tab.new(cmd, comment=comment)
        cron_job.minute().on(min)
        cron_job.hour().on(hour)
        #writes to crontab
        tab.write()
        Log.debug(self, "Cron is set:\n" + tab.render())<commit_msg>added check_isexist function<commit_after>from crontab import *
from ee.core.shellexec import EEShellExec
from ee.core.logging import Log

"""
Set CRON on LINUX system.
"""

class EECron():
    def setcron_daily(self,cmd,comment='Cron set by EasyEngine',user='root',min=0,hour=12):
        if not self.check_isexist(self,cmd):
            tab = CronTab(user=user)
            cron_job = tab.new(cmd, comment=comment)
            cron_job.minute().on(min)
            cron_job.hour().on(hour)
            #writes to crontab
            tab.write()
            Log.debug(self, "Cron is set:\n" + tab.render())

    #Check if cron already exist
    def check_isexist(self,cmd):

         if EEShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)):
             Log.debug(self, "Cron already exist")
             return True
         else:
             return False
{'fraction_non_alphanumeric': 0.13155949741315595, 'fraction_numerical': 0.005173688100517369, 'mean_word_length': 2.6106666666666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3166881', 'n_tokens_mistral': 468, 'n_tokens_neox': 454, 'n_words': 101}