Skip to content

Commit

Permalink
Major update: introduction of running monitor.py infinitely
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuinigeRijder committed Oct 14, 2024
1 parent 1e1b506 commit 84f6482
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
21 changes: 21 additions & 0 deletions logging_config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[loggers]
keys=root

[handlers]
keys=stdout

[formatters]
keys=simpleFormatter

[logger_root]
level=INFO
handlers=stdout

[handler_stdout]
class=StreamHandler
formatter=simpleFormatter
args=(sys.stdout,)

[formatter_simpleFormatter]
format=%(asctime)s: %(levelname)s: %(message)s
datefmt=%Y%m%d %H:%M:%S
23 changes: 23 additions & 0 deletions run_monitor_infinite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# ---------------------------------------------------------------
# A script to run monitor infinite.
# if still running, do not start new one
# Assumption is that monitor.cfg is configured to run infinite (monitor_infinite = True) and
# monitor_execute_commands_when_something_written_or_error is configured to run summary.py and/or dailystats.py, e.g.
# monitor_execute_commands_when_something_written_or_error = python -u summary.py sheetupdate > summary.log;python -u dailystats.py sheetupdate > dailystats.log
# Add to your crontab to run once per hour to restart after crashes or reboot
# 0 * * * * ~/hyundai_kia_connect_monitor/run_monitor_infinite.sh >> ~/hyundai_kia_connect_monitor/crontab_run_monitor_infinite.log 2>&1
# ---------------------------------------------------------------
script_name=$(basename -- "$0")
cd ~/hyundai_kia_connect_monitor

now=$(date)
if pidof -x "$script_name" -o $$ >/dev/null
then
echo "$now: $script_name still running"
else
echo "$now: starting $script_name" >> run_monitor_infinite.log
/usr/bin/python -u ~/hyundai_kia_connect_monitor/monitor.py >> run_monitor_infinite.log 2>&1
now=$(date)
echo "$now: $script_name exited" >> run_monitor_infinite.log
fi

0 comments on commit 84f6482

Please sign in to comment.