What is the best way to run a bash script periodically?
-
- SamyGO Project Donor
- Posts: 161
- Joined: Sun May 03, 2015 6:11 am
What is the best way to run a bash script periodically?
I need to run my custom bash script to check if TV uptime is more than X(configurable) then TV reboot itself using 'micom reboot'.
I already know that TV always returns '1970' date! and also I know that crontab is not available on TV.
What is the best way to run a script periodically to check if uptime is more than X hours and after that reboot TV? (I need a way with minimum impact to TV's functionality)
My bad solution is writing a service and use some scheduling method on it and with helps of Telnet and checking TV's uptime, Service can easily send 'micom reboot' to TV. But in this way I have to have an always power on computer beside of my TV!
I already know that TV always returns '1970' date! and also I know that crontab is not available on TV.
What is the best way to run a script periodically to check if uptime is more than X hours and after that reboot TV? (I need a way with minimum impact to TV's functionality)
My bad solution is writing a service and use some scheduling method on it and with helps of Telnet and checking TV's uptime, Service can easily send 'micom reboot' to TV. But in this way I have to have an always power on computer beside of my TV!
Re: What is the best way to run a bash script periodically?
Use getcurrenttimefromtv and do what you wantsmart_lover wrote:I need to run my custom bash script to check if TV uptime is more than X(configurable) then TV reboot itself using 'micom reboot'.
I already know that TV always returns '1970' date! and also I know that crontab is not available on TV.
What is the best way to run a script periodically to check if uptime is more than X hours and after that reboot TV? (I need a way with minimum impact to TV's functionality)
My bad solution is writing a service and use some scheduling method on it and with helps of Telnet and checking TV's uptime, Service can easily send 'micom reboot' to TV. But in this way I have to have an always power on computer beside of my TV!
I do NOT support "latest fw" at ALL. If you have one you should block updates on router and wait for it to STOP being "latest":)
If you want me to help you please paste FULL log(s) to "spoiler"/"code" bbcodes or provide link(s) to pasted file(s) on https://pastebin.com Otherwise "NO HELP"!!!
If you want root DISABLE internet access to your device!!!!
DO NOT EVER INSTALL FIRMWARE UPGRADE !!!!
If you want me to help you please paste FULL log(s) to "spoiler"/"code" bbcodes or provide link(s) to pasted file(s) on https://pastebin.com Otherwise "NO HELP"!!!
If you want root DISABLE internet access to your device!!!!
DO NOT EVER INSTALL FIRMWARE UPGRADE !!!!
-
- SamyGO Project Donor
- Posts: 161
- Joined: Sun May 03, 2015 6:11 am
Re: What is the best way to run a bash script periodically?
Where can I find this function? It seems In E series there is no such function. I need it in both E and H series.sectroyer wrote:Use getcurrenttimefromtv and do what you want
Actually I need a way to run my script periodically to check TV uptime( I already knew about getting TV's uptime).
please help me a little more!
You do not have the required permissions to view the files attached to this post.
Re: What is the best way to run a bash script periodically?
Use search...
SpoilerShow
sectroyer wrote:Simple App that just gets Current Time directly from TV (based on hedaks findings)
Sample usage:To set the current time run this:Code: Select all
/getsetcurrenttimefromtv -n exeDSP Current Time: 1393671424 Current TimeZone Number: 9 Current TimeZone Offset: 60 The current date/time is: Sat Mar 1 10:57:04 2014 Current Time+Offset: 1393675024 The current date/time+offset is: Sat Mar 1 11:57:04 2014
EDIT:Code: Select all
/getsetcurrenttimefromtv -n exeDSP -s
New version. Added D/E support.
EDIT2:
Update. Added TimeZone support.
EDIT3:
New version. The app now also sets the time.
EDIT4:
Update. Added "date mode".
EDIT5:
Update. Added set2 option (forces +offset on C).
EDIT6:
Update. Removed set2 option (now app always adds +offset to current time). Add --utc switch.
EDIT7:
Update. Added "date mode" for correct time zone (-U)
If you want to use getsetcurrenttimefromtv instead of default date command add this line to $SYSROOT/etc/rc.sysinit:
Or if you set your timezone correctly use this:Code: Select all
echo "alias date='getsetcurrenttimefromtv -n exeDSP -D'" >> /dtv/.ashrc
Code: Select all
echo "alias date='getsetcurrenttimefromtv -n exeDSP -U'" >> /dtv/.ashrc EDIT8: Added support for additional display formats (-Y,-M,etc.)
LE40B653T5W,UE40D6750,UE65Q8C
Have questions? Read SamyGO Wiki, Search on forum first!
FFB (v0.8), FFB for CI+ . Get root on: C series, D series, E series, F series, H series. rooting K series, exeDSP/exeTV patches[C/D/E/F/H]
DO NOT EVER INSTALL FIRMWARE UPGRADE
Have questions? Read SamyGO Wiki, Search on forum first!
FFB (v0.8), FFB for CI+ . Get root on: C series, D series, E series, F series, H series. rooting K series, exeDSP/exeTV patches[C/D/E/F/H]
DO NOT EVER INSTALL FIRMWARE UPGRADE
-
- SamyGO Project Donor
- Posts: 161
- Joined: Sun May 03, 2015 6:11 am
Re: What is the best way to run a bash script periodically?
I already searched with no success before my post!juusso wrote:Use search...
I searched 'getcurrenttimefromtv'(as sectroyer said) instead of 'getsetcurrenttimefromtv'
Anyway, Thanks for your help to correct my typo.
Does this lib works in H series?
But my main question is how can I run my script(bash or anything equivalent) periodically in TV.
Re: What is the best way to run a bash script periodically?
smart_lover wrote: But my main question is how can I run my script(bash or anything equivalent) periodically in TV.
Code: Select all
while
do
sleep 1
echo "run your 'script(bash or anything equivalent) periodically in TV.'";
done
I do NOT support "latest fw" at ALL. If you have one you should block updates on router and wait for it to STOP being "latest":)
If you want me to help you please paste FULL log(s) to "spoiler"/"code" bbcodes or provide link(s) to pasted file(s) on https://pastebin.com Otherwise "NO HELP"!!!
If you want root DISABLE internet access to your device!!!!
DO NOT EVER INSTALL FIRMWARE UPGRADE !!!!
If you want me to help you please paste FULL log(s) to "spoiler"/"code" bbcodes or provide link(s) to pasted file(s) on https://pastebin.com Otherwise "NO HELP"!!!
If you want root DISABLE internet access to your device!!!!
DO NOT EVER INSTALL FIRMWARE UPGRADE !!!!
Re: What is the best way to run a bash script periodically?
I guess it should. Try and tell ussmart_lover wrote:Does this lib works in H series?
LE40B653T5W,UE40D6750,UE65Q8C
Have questions? Read SamyGO Wiki, Search on forum first!
FFB (v0.8), FFB for CI+ . Get root on: C series, D series, E series, F series, H series. rooting K series, exeDSP/exeTV patches[C/D/E/F/H]
DO NOT EVER INSTALL FIRMWARE UPGRADE
Have questions? Read SamyGO Wiki, Search on forum first!
FFB (v0.8), FFB for CI+ . Get root on: C series, D series, E series, F series, H series. rooting K series, exeDSP/exeTV patches[C/D/E/F/H]
DO NOT EVER INSTALL FIRMWARE UPGRADE
-
- SamyGO Project Donor
- Posts: 161
- Joined: Sun May 03, 2015 6:11 am
Re: What is the best way to run a bash script periodically?
Of course it helps!sectroyer wrote:smart_lover wrote: But my main question is how can I run my script(bash or anything equivalent) periodically in TV.hope this helpCode: Select all
while do sleep 1 echo "run your 'script(bash or anything equivalent) periodically in TV.'"; done
I use below script
Code: Select all
#!/bin/sh
upSeconds="$(cat /proc/uptime | grep -o '^[0-9]\+')"
upMins=$((${upSeconds} / 60))
until [ "${upMins}" -gt "2880" ] ; do
sleep 30m
upSeconds="$(cat /proc/uptime | grep -o '^[0-9]\+')"
upMins=$((${upSeconds} / 60))
done
samyGOrc -p $(pidof exeTV || pidof exeDSP) 152
Is above script a bad script or not? It is important to me that above script do not cause a TV crash at the end of day. I need an optimize script.
F.Y.I: I need some script to power off TV's panel after 48 hours of continues TV power on. Is there any solution available that is more optimize than my solution?
Re: What is the best way to run a bash script periodically?
Name your script 99_99_myscript.init, then no problems
I do NOT support "latest fw" at ALL. If you have one you should block updates on router and wait for it to STOP being "latest":)
If you want me to help you please paste FULL log(s) to "spoiler"/"code" bbcodes or provide link(s) to pasted file(s) on https://pastebin.com Otherwise "NO HELP"!!!
If you want root DISABLE internet access to your device!!!!
DO NOT EVER INSTALL FIRMWARE UPGRADE !!!!
If you want me to help you please paste FULL log(s) to "spoiler"/"code" bbcodes or provide link(s) to pasted file(s) on https://pastebin.com Otherwise "NO HELP"!!!
If you want root DISABLE internet access to your device!!!!
DO NOT EVER INSTALL FIRMWARE UPGRADE !!!!
-
- SamyGO Project Donor
- Posts: 161
- Joined: Sun May 03, 2015 6:11 am
Re: What is the best way to run a bash script periodically?
Let assume I copy my script to 'PanelOff' script and put it to ' /mtd_rwcommon/' folder. Is is better to use following code(Run command in background)sectroyer wrote:Name your script 99_99_myscript.init, then no problems
Code: Select all
nohup /mtd_rwcommon/PanelOff> /dev/null 2>&1 &
I am thinking if my script contains infinitive 'until' condition then .init script will not finish and it lead TV to not boot properly(prevent progressing other .init files and TV booting process)