1. SSH Into Controller
Self explainatory.
2. Create Shell Script
Create the folder, the file...
mkdir /usr/share/cron/
vi /usr/share/cron/cgrestart.sh
The script is...
#!/bin/sh
# This file is for cron job
C=`pidof cgminer | wc -w`
if [ "$C" != "1" ]; then
/etc/init.d/cgminer stop
/etc/init.d/cgminer start
exit 0;
fi
A=`cat /tmp/cm.log`
B=`cgminer-api | grep "^ \[Accepted\]"`
echo $B > /tmp/cm.log
if [ "$A" == "$B" ]; then
/etc/init.d/cgminer stop
/etc/init.d/cgminer start
exit 0;
fi
3. Assign Execute Permissions to Script
chmod 755 /usr/share/cron/cgrestart.sh
4. Add the Script to CronTab
Edit contrab with the crontab -e
command and add the following line:
0 */4 * * * /usr/share/cron/cgrestart.sh
This example will force a restart every 4 hours.
Note:
For more examples on CronTab settings, check out: CronTab.Guru
Optional: Setup Alerts
Receive alerts whenever your job fails to launch or complete. Create an alert at WDT.io and add the following suffix to the job in crontab:
&& wget -qT 30 http://k.wdt.io/%ACCOUNT_ID%/%ALERT_NAME%
Example:
&& wget -qT 30 http://k.wdt.io/71gd72ha/myalert01