check_service_and_restart_if_failed
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
check_service_and_restart_if_failed [2020/07/27 01:28] – k2patel | check_service_and_restart_if_failed [2020/08/10 02:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 15: | Line 15: | ||
| | ||
fi | fi | ||
+ | </ | ||
+ | |||
+ | for python | ||
+ | |||
+ | <code python> | ||
+ | # | ||
+ | import os | ||
+ | import logging | ||
+ | from systemd import journal | ||
+ | |||
+ | def main(serviceName): | ||
+ | status = os.system(' | ||
+ | finisher(status) | ||
+ | |||
+ | def finisher(status): | ||
+ | if status is not 0: | ||
+ | status = os.system(' | ||
+ | print(status) | ||
+ | if status is not 0: | ||
+ | log.error(' | ||
+ | else: | ||
+ | log.info(' | ||
+ | |||
+ | if __name__ == " | ||
+ | |||
+ | # Initialize and handle options | ||
+ | log = logging.getLogger(__file__) | ||
+ | log.addHandler(journal.JournaldLogHandler()) | ||
+ | log.setLevel(logging.INFO) | ||
+ | |||
+ | # Define service array | ||
+ | serviceName = [" | ||
+ | for service in serviceName: | ||
+ | main(service) | ||
</ | </ |
check_service_and_restart_if_failed.1595813299.txt.gz · Last modified: 2020/08/10 02:30 (external edit)