<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 23, 2019, 13:27 Peter Bennett <<a href="mailto:pb.mythtv@gmail.com">pb.mythtv@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
What I do is as follows:<br>
<br>
I have a script that gets run as the pre-shutdown check command. In <br>
there I check date and time and decide whether certain things need to be <br>
done (backup, optimize, other things). If it decides that, for example, <br>
dailyrun.sh needs to run, it returns 1 to the check and starts up <br>
dailyrun.sh. It continues to return 1 to the check until dailyrun.sh is <br>
finished, then returns 0 which allows the shutdown. I keep files in a <br>
directory with dates so that it knows if something is already run for <br>
the day and does not run it again.<br>
<br>
See <br>
<a href="https://github.com/bennettpeter/mythscripts/blob/master/install/opt/mythtv/bin/mythshutdown.sh" rel="noreferrer noreferrer" target="_blank">https://github.com/bennettpeter/mythscripts/blob/master/install/opt/mythtv/bin/mythshutdown.sh</a> <br>
for my script. It does a lot more than you are looking for, but may give <br>
you some ideas. That script runs "dailyrun.sh" once a day, the first <br>
time a shutdown occurs. I am not sure how you will know the last time a <br>
shutdown occurs for the day, but running your optimize at the first <br>
shutdown of the day should be just as good.<br>
<br>
Peter<br>
_________________________________________<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Yes Peter I think this is more of what I'm looking for, my question now is, since I already have a pre shutdown check working (to check if I'm logged in or not) how can these two be combined or will yours do what mine is already doing and thereby repaceable?</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>