Tools
From AMule Project FAQ
Linux
Bash script to restart aMule whenever connection is lost
Sometimes aMule loses the connection and not reconnects automtically (it's could happen when aMule is running for many days). Here is the bash script for Linux, posted by telefono in the aMule-Forum, which checks if aMule has lost the connection and, if yes, restarts the aMule daemon.
The script simple checks if aMule is not downloading and if the total sources is less than 50. In order to use the script, you need to put it in /etc/cron.hourly/ and call it "amulereset".
sudo touch /etc/cron.hourly/amulereset
now set some permissions:
sudo chmod 755 /etc/cron.hourly/amulereset
and open it…
sudo gedit /etc/cron.hourly/amulereset
then copy and paste the follow script:
#!/bin/bash # some settings host=localhost port=4712 pass=YOUPASSWORD # if the clients on quee is lees than the setted number, restart (if not downloading) minClientOnQuee=50 #cheking the status r=`amulecmd -h $host -p $port -P $pass -c status` #retrieving info download=`echo $r | grep -o 'Download: .* Up' | sed -e 's/Download: //' -e 's/ > Up//' | sed -e 's/Download: //' -e 's/ kB\/s//' | sed -e 's/Download: //' -e 's/ bytes\/sec//'` upload=`echo $r | grep -o 'Upload: .* Cl' | sed -e 's/Upload: //' -e 's/ kB\/s > Cl//'` ed2k=`echo $r | grep -o 'eD2k: .* Kad' | sed -e 's/eD2k: //' -e 's/ > Kad//'` kad=`echo $r | grep -o 'Kad: .* Dow' | sed -e 's/Kad: //' -e 's/ > Dow//'` clientsOnQuee=`echo $r | grep -o 'Clients in queue: .* > Tot' | sed -e 's/Clients in queue: //' -e 's/ > Tot//'` totalSources=`echo $r | grep -o 'Total sources: .*' | sed -e 's/Total sources: //' -e 's/ //'` #some echo's for debug echo "Download : $download" echo "Upload : $upload" echo "clientsOnQuee : $clientsOnQuee" echo "totalSources : $totalSources" # only if not downloading if [ "$download" = 0 ] then if [ "$clientsOnQuee" -lt "$minClientOnQuee" ] then /etc/init.d/amule-daemon restart exit fi fi exit