aMule Forum

English => aMule crashes => Topic started by: theojk on February 20, 2008, 08:13:27 PM

Title: autorestart script crashes amuled on cron job
Post by: theojk on February 20, 2008, 08:13:27 PM
I have the following problem:

amuled sometimes crashes. Thats why I written a small restart-script:
Code: [Select]
#!/bin/sh
LOG=/home/username/amule_watch.log
TCPPORT=4669
if netstat -n -l | grep -q 14669 ; then
        echo "ok"
else
        echo "Neustart --> `date`" >> ${LOG}
        /etc/init.d/amule stop
        sleep 30
        /etc/init.d/amule start
fi
It just checks if the amuled is still running and if not it restarts amuled :



when I run this script from bash its all ok. It tells me "ok" or it stops the amuled, wait 30 seconds and start it again with following output
Code: [Select]
Stopping amuled: Starting amuled: amuled: OnInit - starting timer
Initialising aMule
Checking if there is an instance already running...
No other instances are running.
amuled: forking to background - see you
amuled.

now I tried to setup a cron job:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/amulewatchdog.sh

when amuled is still running, all is ok. But when amuled is not running anymore, the script should restart it.
but everytime when cron starts the script the following error is mailed:
Code: [Select]
From root@xxxx.xxxx  Wed Feb 20 19:10:33 2008
X-Original-To: root
Delivered-To: root@xxxx.xxxx
From: root@xxxx.xxxx
To: root@xxxx.xxxx
Subject: Cron <root@eselchen> /usr/local/bin/amulewatchdog.sh
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Date: Wed, 20 Feb 2008 19:05:01 +0100 (CET)

Stopping amuled: Starting amuled: Assertion failed: Path.cpp:CPath:259: Assertion 'm_filesystem.Length()' failed.

Backtrace follows:
[4] CPath in Path.cpp:260
[5] CKnownFile::LoadTagsFromFile(CFileDataIO const*) in KnownFile.cpp:529
[6] CKnownFile::LoadFromFile(CFileDataIO const*) in KnownFile.cpp:634
[7] CKnownFileList::Init() in KnownFileList.cpp:97
[8] CKnownFileList in KnownFileList.cpp:58
[9] CamuleApp::OnInit() in amule.cpp:710
[10] CamuleDaemonApp::OnInit() in amuled.cpp:607
[11] wxAppConsole::CallOnInit() in app.h:76
[12] wxEntry(int&, wchar_t**) in /usr/local/lib/libwx_baseud-2.8.so.0[0xb7e31f4e]
[13] wxEntry(int&, char**) in /usr/local/lib/libwx_baseud-2.8.so.0[0xb7e32180]
[14] main in amuled.cpp:102
[15] __libc_start_main in /lib/libc.so.6[0xb7b34fe0]
[16] _start in :0

It only crashes when started with cron. When I start the script directly it s all ok.

Title: Re: autorestart script crashes amuled on cron job
Post by: Xaignar on February 21, 2008, 12:37:44 AM
From which date is the snapshot you're using, and what is your sytem locale?
Title: Re: autorestart script crashes amuled on cron job
Post by: jutso on April 07, 2008, 08:11:18 AM
See here : How to run a GUI programs with cron
http://ubuntuforums.org/archive/index.php/t-185993.html

Title: Re: autorestart script crashes amuled on cron job
Post by: Crakem on April 07, 2008, 11:56:43 PM
Remember running script as user, never as root or don't work as you spec, in mandriva i could add script like this:
Code: [Select]
# crontab -u <user_running_amuled> -echange <user_running_amuled> with yours. And edit like this:
Code: [Select]
*/5 * * * * $HOME/emuleSave and close. This check five minutes each.

My script is like this:
Code: [Select]
#!/bin/bash
startamuled()
{
if [ $UID != 0 ]
then
        /usr/bin/amuled -f
        logger "Amuled have been started"
else
        echo "You can't run this script as root"
fi
}
if ps -C amuled > /dev/null
then
        :
else
        logger "Amuled have crashed. Restarting"
        startamuled
fi
exit
Worked fine but I don't like so boring output in /var/log/messages from cron. Maybe it will be better amuled adding respawn capabilities :P
I have to change it to add CORE backtraces support when I looking for a place to sending it :)