How to auto start the momocash masternode - momopay/momo GitHub Wiki
1. init php env
apt-get install php-cli
if not run
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
apt-key adv —recv-keys —keyserver keyserver.ubuntu.com 4F4EA0AAE5267A6C
sudo apt-get update
apt-get install php-cli
2.config the php code
<?php
$cmd1 = “ps -ef | grep momod |wc -l”;
exec($cmd1, $t);
print_r($t);
if($t0 == 1 || $t0 == 3){
$cmd2 = “/data/momo/src/momod -daemon > /dev/null 2>&1 &”;
exec($cmd2, $m);
print_r($m);
echo “start momod *******”.PHP_EOL;
}else{
echo “it is running”.PHP_EOL;
}
sleep(120);
$cmd3 = “/data/momo/src/momo-cli masternode status”;
$n = shell_exec($cmd3);
$n = json_decode($n,true);
print_r($n);
if($n[‘status’] != ‘Masternode successfully started’){
$cmd4 = “/data/momo/src/momo-cli masternode start-alias seed58”;
$y = shell_exec($cmd4);
$y = json_decode($y, true);
if($y[‘result’] = ‘successful’){
echo “start-alias successful”.PHP_EOL;
}
}
?>
3.put at /home, modify the MN id and momod && momo-cli dir location
4.config the crontab
crontab -e
add
*/15 * * * * php /home/check_momod.php
every 15 min execute 1 time