Site icon Learning & Doing

Membuat script running background per detik

buat script nya nano /home/kill.sh

#!/bin/bash
for i in `ps -ef |grep danielha|awk ‘{print $2}’`;do kill -9 $i;done

bikin script per detik nya :

nano perdetik.sh

#!/bin/bash
while true
do
/home/kill.sh
sleep 1
done

Running background :

/bin/sh perdetik.sh > /dev/null 2>&1 &

kemudian taro di rc.local supaya kalo di reboot aktif lagi script nya

nano /etc/rc.local

/home/kill1.sh > /dev/null 2>&1 &

cara stop :

ps -ax |grep -i perdetik

kill -9 PID

Exit mobile version