403Webshell
Server IP : 66.29.132.122  /  Your IP : 3.139.83.210
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/proc/self/root/proc/thread-self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/opt/imunify360/venv/share/imunify360/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/proc/self/root/proc/thread-self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/opt/imunify360/venv/share/imunify360/scripts/delay_on_cron_call.py
#!/opt/imunify360/venv/bin/python3
"""
Script for internal use in cron update scripts.

This script detects when parent call was maid from cron job and
apply the random delay in 60 minutes
"""

import os
import psutil
import random
import time

MAX_SLEEP_TIME = 3600


def is_current_process_cron_child():
    pid = os.getpid()
    try:
        process = psutil.Process(pid)
        parents = process.parents()

        # True for cron cronie anacron and etc..
        return any(is_cron(proc.name().lower()) for proc in parents)
    except psutil.NoSuchProcess:
        print("Unable to determine parent process ID.")
        return False


def is_cron(proc_name: str):
    return "cron" in proc_name and not "imunify" in proc_name


def sleep_in_cron():
    try:
        if is_current_process_cron_child():
            sleep_time = random.randint(0, MAX_SLEEP_TIME)
            print(f"Wait for {sleep_time} seconds before starting updates")
            time.sleep(sleep_time)
        else:
            print("Not in cron, run update immediately")
    except Exception as e:
        print("An error occurred while waiting: ", e)


sleep_in_cron()

Youez - 2016 - github.com/yon3zu
LinuXploit