Answer the question
In order to leave comments, you need to log in
Bash script for Linux that restarts a program/service automatically after a given time?
There is Ubuntu Server 16.04 LTS 64 bit.
There is a program (server) .x86_64 that has the problem of "hanging" after a while, and therefore a bash script is needed that will automatically restart the program after a specified time.
If there are any solutions, I would be happy to hear.
Answer the question
In order to leave comments, you need to log in
Either fix the bydlocode,
Or put it in systemd and put the systemctl restart call in cron [name of the bydlocode piece]
nano /usr/local/bin/killproc.sh
there
#!/bin/bash
PROCFOLDER="/bin/" #папка процесса
PROCNAME="Thunar"; #имя процесса
kill `ps aux | grep $PROCNAME| tail -n2 | head -n1 |awk {'print $2'}`
$PROCFOLDER$PROCNAME
chmod +x /usr/local/bin/killproc.sh
nano /etc/crontab
*/10 * * * * root /usr/local/bin/killproc.sh
as a rule, the construction is used
/etc/init.d/.... status || /etc/init.d... restart
(there are many options)
where || the exit code of the program is false
, that is, they check the status of the daemon.
it would not be bad to say what kind of software.
monit
In the settings, specify the criterion for the process to hang, and the action to take when it occurs
There is such a heartbeat event for servers, you can read it here
https://www.opennet.ru/docs/RUS/ha_cluster/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question