it depends on how complex you want to end up.
regarding (1) you can restart a failed script by placing it in an infinite loop within a parent shell script if you are sure you debugged it enough so not to end up with an infinite pile of core-dumps. You can also have cron checking on it and respawn it if it disappears from the process list. You can also have cron sending it periodically a signal to dump diagnostics. In any event "perpetual" script or cron, it will have to sleep for a while in a loop. (1) makes it easier to change that sleep interval and also importantly, you can wake it up with a signal in order to respond to emergencies. So "continuously running" has a lot of merrits too. And it can too reschedule its wake up time with a Perl alarm (need example code?).
nit-picking: (3) is best with at.
With (1) you can expand your system to scan a queue of future actions from a database: open curtains at 8, close curtains at 5, water plants, etc. And execute if it's time. Each action is consumed unless it is a recurrent type of action (like the curtains). You can have many types of actions and your script would know how to handle each. The database/queue-of-actions can be updated independently and perhaps remotely or by voice. Also a speech synthesizer can read out the entries to the database of actions-to-do when instructed.
With (1) I would use a cron job to only make sure that the script is alive, or to periodically send it a signal to dump some diagnostics to email them to you. To have the script running even after a reboot, turn it into a service with systemctl - that buys you a free respawning within reason.
For your current spec I would go with (2): script is executed every 5 mins, if sunrise it opens, if sunset (calculate it) it closes. And it short-circuits if time of day is not interesting e.g. midnight. That's 12*24 times a day. Nothing really.
edit: basically you end up with a home-cron hehe
In reply to Re: Continuous or timed?
by bliako
in thread Continuous or timed?
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |