From 4272418cb0d7866865836283108784408a154931 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 13 Feb 2025 06:52:00 -0500 Subject: [PATCH] automated terminal push --- smart-cron-builder.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/smart-cron-builder.py b/smart-cron-builder.py index 20f30e3..1b7dda3 100755 --- a/smart-cron-builder.py +++ b/smart-cron-builder.py @@ -30,6 +30,8 @@ def buildLogFileName(): node_id= logFileDir + "yankee-node-" + server_ip + "-" + server_hostname + ".log" + node_id= "/root/Desktop/consumer.log" + return node_id except socket.gaierror: @@ -54,6 +56,8 @@ def buildCronExecuteTime(): def buildCronSituation(): + return buildCronExecuteTime() +"/yankee-gnome-fire-consumer/consumer.bash >> " + buildLogFileName() + " 2>&1" + return buildCronExecuteTime() +" python3 /yankee-gnome-fire-consumer/consumer.py >> " + buildLogFileName() + " 2>&1" #### @@ -111,8 +115,9 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin * * * * * /tmp/ping2.bash >> /var/log/cron.log 2>&1""" try: - # Check if the file exists and delete if it does + if os.path.exists(file_path): + os.remove(file_path) with open(file_path, "w") as f: @@ -134,9 +139,9 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin f.write(sep) f.write(sep) - f.write("* * * * * /yankee-gnome-fire-consumer/consumer.bash >> /var/log/consumer.log 2>&1") - f.write(sep) - f.write(sep) + #worksf.write("* * * * * /yankee-gnome-fire-consumer/consumer.bash >> /var/log/consumer.log 2>&1") + #f.write(sep) + #f.write(sep) print(f"Crontab written to '{file_path}' successfully.")