0

I have an application that occasionally closes due to some runtime error or DDOS attack. The application runs inside a section of the Screen, so I need to access the server and type the command screen -S name ./start_app.sh and exit with ctrl + a ctrl + d. I found a post here where it is possible to use the crontab, but I do not want to restart the application execution, I just want it to verify that the application is running, in case the application is not running, it automatically starts the screen detached with the application running . Is it possible?

1

You appear to be confusing apparent outputs with background processes and detachable tty's. You might want to name the program to get better answers - my answer below is thus intrinsically generic.

If you know the name of the program you can check if its running by looking at the process list - however you indicate that it is subject to a DDOS attack. If thats the case I surmise its talking on a port, and you can monitor its availability either by checking the port (for example using netcat) or check if the process is still running using fuser (which can see what, if any process is bound to a port).

You should be able to script something and run it from crontab periodically to check the status of the service and, for example, email you if it fails. You can also use tools like Nagios to monitor your system and provide states.

Another approach could be to systematically look for failure messages in the log file and immediately take action on these failures. This is not as bulletproof as the methods above, but if the failure rates are well defined, it has the advantage of being able to do it in real-time without waiting for cron. You can use/abuse fail2ban to do this kind of monitoring.

Using screen is probably a red herring, as its really just showing you the output of a given tty - ie its a tool for human interaction, not for machine monitoring.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.