L
L
l2p2015-06-19 12:05:35
linux
l2p, 2015-06-19 12:05:35

How to catch a process stop?

PHP scripts are constantly running on the server in the background. I hung all the scripts in one file /etc/init.d/ to add autorun. But several times a day problems arise - either the process hangs, but the script is not executed in any way, or the process disappears altogether. How can I think through both situations? I run PHP scripts with start-stop-daemon and create pidfile. I delete processes by deleting these pidfiles. There is an idea that it is possible to process exceptions of each function in the script itself and, if the same error occurs several times, then reset using /etc/init.d/ (but I don’t know how to receive error data). Help Wanted.
Additional question. On the server, ssh is constantly scanned (different ips and different ports). Is it enough to give 2-3 attempts to authorize root, change the username and port?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
PrAw, 2015-06-24
@l2p

On the main issue - to keep a text log from the script.
Ideally, first figure out why it falls, and then fence the bike. Most likely, either the matter is in the non-response of something remote or an exceptional situation. In the case of php, you can also keep an error log
php.net/manual/ru/function.error-log.php
in specific scripts to prescribe where they should admit their mistakes.
On a side note - fail2ban
default settings already include autoban for a short period of time for active pickers.

A
Alexander, 2015-06-19
@NeiroNx

Probably you need to make a script that will monitor the status of the others and run it via cron.
Well, set up error logging in scripts, so that later you know where they fall.

A
athacker, 2015-06-19
@athacker

SSH to a non-standard port.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question