From 9a7eacf05d9b77e7fcd80fd4c0b0baf956ff61c8 Mon Sep 17 00:00:00 2001 From: "connorc@orbitnode.net" Date: Sun, 19 Mar 2023 18:19:17 -0600 Subject: [PATCH] update mysql_database_config.rb --- mysql_database_config.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mysql_database_config.rb b/mysql_database_config.rb index eb2e1a7..609d860 100644 --- a/mysql_database_config.rb +++ b/mysql_database_config.rb @@ -55,6 +55,17 @@ class MysqlDatabaseConfig @logger.error("An error occurred while generating MySQL database configuration file: #{e.message}") @logger.debug("Backtrace: #{e.backtrace}") end + + # ask the user if they want to setup a cron job for the program + cron_job = prompt_bool('Do you want to setup a cron job for this program?', default: false) + if cron_job + # how often the program should run + cron_interval = prompt('How often do you want the program to run? (in minutes, e.g. "60" for every hour)', + default: '60').to_i + # write the cron job to crontab + `echo "*/#{cron_interval} * * * * /usr/bin/PixelatedStudios/Ruby/Ru-b2-SQL-Backups/starter.rb" >> /etc/crontab` + @logger.info("Cron job added to /etc/crontab to run every #{cron_interval} minutes.") + end end end