0

Recently I have a program which does daily restarts with a while loop that every time the program shuts down, the while loop will bring it back up.

But I want to change that to that it will only start up at a specific time every single day in a specified screen (screen -r 39191)

Current code:

while true; do ./program; done;

I am trying to do something like this

if time = 6 am or when I paste this script in console; do ./program; done;

Is this possible on Linux (Ubuntu)? Thanks in advance

edward
  • 39
  • 6
  • 2
    If you want something to run every day at a certain time, use `cron`. – William Pursell Feb 26 '18 at 12:24
  • Try: `sleep $((60*60*24))` – ceving Feb 26 '18 at 12:25
  • 1
    Sounds like you are looking for a self-scheduling `at` job at the beginning of `./program` itself. – tripleee Feb 26 '18 at 12:44
  • I am abit scared of cron jobs to be honest as I have never used it, I have looked into it abit and it looks like I could damage some things if I do it in correctly. About the sleep thing, how will it be able to sleep if the actual program is going to be run in the shell? The reason why I want this is because I suspect the while loop that I included in "current code" to eat too much CPU due to the fact that it simply don't give it any time to load off its process when closing down, it immediately tries to start a new program when down, is this theory true or am I speculating too hard? – edward Feb 26 '18 at 16:32

0 Answers0