Skip to content

Cron service restart

Lars The edited this page Jan 11, 2021 · 1 revision

#Automatic service restart with cron

Simple command for restarting the minisatip process in a STB only if all tuners are not in use:

wget -qO- http://127.0.0.1:8080/state.json | awk -F: '/ad_enabled/ {print $2; fflush()}' | grep -qv 1 && echo restarting... && /etc/init.d/minisatip restart

This command does this:

  1. It gets the status of the minisatip process using the web interface.
  2. It parses the JSON output to get the tuner status.
  3. It checks if any tuner is ON (when it sees a 1 inside the "ad_enabled" variable).
  4. If all tuners are OFF then it calls to restart the minisatip service.

So this is useful to insert it in the /etc/crontab file of your STB to restart the minisatip process every night (or every hour) if you're not using it. For example to restart every night at 4:45am:

45 4 * * * root wget -qO- http://127.0.0.1:8080/state.json | awk -F: '/ad_enabled/ {print $2; fflush()}' | grep -qv 1 && /etc/init.d/minisatip restart