aturan : "Cek status terlebih dahulu.Jika XAMPP/LAMPP mati atau error, baru dijalankan ulang."
- Buat script monitoring
vi /usr/local/bin/check_lampp.sh
- isi:
#!/bin/bash
LAMPP="/opt/lampp/lampp"
LOG="/var/log/lampp-monitor.log"
export PATH_ORACLE="/opt/lampp/lib/instantclient-11.2.0.3.0"
export LD_LIBRARY_PATH="$PATH_ORACLE"
export TNS_ADMIN="$PATH_ORACLE"
export ORACLE_HOME="$PATH_ORACLE"
DATE=$(date '+%Y-%m-%d %H:%M:%S')
# Cek apakah LAMPP sedang berjalan
if "$LAMPP" status 2>&1 | grep -qiE "running|already running"; then
echo "$DATE - LAMPP OK / RUNNING" >> "$LOG"
exit 0
fi
# Jika tidak running, coba restart
echo "$DATE - LAMPP STOP/ERROR - melakukan restart..." >> "$LOG"
"$LAMPP" stop >> "$LOG" 2>&1
sleep 3
"$LAMPP" start >> "$LOG" 2>&1
sleep 5
# Cek kembali setelah restart
if "$LAMPP" status 2>&1 | grep -qiE "running|already running"; then
echo "$DATE - LAMPP berhasil START kembali" >> "$LOG"
else
echo "$DATE - WARNING: LAMPP gagal START!" >> "$LOG"
fi
- Simpan kemudian jalankan :
chmod +x /usr/local/bin/check_lampp.sh
- Test manual
/usr/local/bin/check_lampp.sh
- kemudian lihat :
cat /var/log/lampp-monitor.log
- cek juga :
/opt/lampp/lampp status
- Buat crontab setiap 5 menit
- edit crontab root :
crontab -e
- tambahkan :
*/5 * * * * /usr/local/bin/check_lampp.sh
- Jadi setiap 5 menit akan menjalankan scrip
- Jalankan ini untuk melihat hasil :
cat /var/log/lampp-monitor.log
- Hasilnya seperti ini :
2026-09-29 11:19:59 - LAMPP OK / RUNNING
2026-09-29 11:25:01 - LAMPP OK / RUNNING
2026-09-29 11:30:01 - LAMPP OK / RUNNING
2026-09-29 11:35:01 - LAMPP OK / RUNNING
2026-09-29 11:40:01 - LAMPP OK / RUNNING
2026-09-29 11:45:01 - LAMPP OK / RUNNING
2026-09-29 11:50:01 - LAMPP OK / RUNNING
2026-09-29 11:55:02 - LAMPP OK / RUNNING
2026-09-29 12:00:01 - LAMPP OK / RUNNING
2026-09-29 12:20:01 - LAMPP OK / RUNNING
2026-09-29 12:25:01 - LAMPP OK / RUNNING
2026-09-29 12:30:01 - LAMPP OK / RUNNING
2026-09-29 12:35:01 - LAMPP OK / RUNNING
2026-09-29 12:40:01 - LAMPP OK / RUNNING
2026-09-29 12:45:01 - LAMPP OK / RUNNING
2026-09-29 12:50:01 - LAMPP OK / RUNNING
2026-09-29 12:55:01 - LAMPP OK / RUNNING
2026-09-29 13:00:01 - LAMPP OK / RUNNING