maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   [SCRIPT] Restart wazapp automatically upon crash! (https://talk.maemo.org/showthread.php?t=85258)

godofwar424 2012-07-04 17:12

[SCRIPT] Restart wazapp automatically upon crash!
 
Hi,

I suffer from alot of random Wazapp crashes due to either signal loss or just PSM interfering.

For the moment I came up with a solution to missing messages due to a crash.

I want to make a script and then have it run every 30 mins or so to check if Wazapp is running and if it isn't restart it.

Here is what I have so far but there are errors I can't seem to solve, hoping you guys can help correct this :)

EDIT: This is the latest version that works!

Code:

#!/bin/sh

#set -x

#
# Variables Section
#==============================================================
# list process to monitor in the variable below.
#{wazapp} /usr/bin/python /opt/waxmppplugin/bin/wazapp/

PROGRAM1="wazapp"


# varible checks to see if $PROGRAM1
# is running.

APPCHK=$(ps aux | grep -C $PROGRAM1)

#
#
#==================================================================

# The ‘if’ statement below checks to see if the process is running
# with the ‘ps’ command.  If the value is returned as a ’0' then
# an email will be sent and the process will be safely restarted.
#


if [ $APPCHK = '0' ];

then

/opt/waxmppplugin/bin/wazapp/wazapp

else

echo 'Wazapp is running'

fi

echo $APPCHK

exit

PS. This idea was taken from this guys idea of a script for a similar purpose.

http://www.savelono.com/linux/bash-a...s-running.html

godofwar424 2012-07-04 19:55

Re: [SCRIPT HELP] Process is running or not
 
Newer Version of the script

Code:

#!/bin/sh

#set -x

#
# Variables Section
#==============================================================
# list process to monitor in the variable below.
#{wazapp} /usr/bin/python /opt/waxmppplugin/bin/wazapp/

PROGRAM1="wazapp"

#lists pid of that process

PID1=$(pidof $PROGRAM1)

#
#
#==================================================================

# The ‘if’ statement below checks to see if the process is running
# with the ‘ps’ command.  If the value is returned as a ’0' then
# an email will be sent and the process will be safely restarted.
#


if [ $PID1 = '' ];

then

/opt/waxmppplugin/bin/wazapp/wazapp

else

echo 'Wazapp is running'

fi

exit


godofwar424 2012-07-04 21:13

Re: [SCRIPT HELP] Process is running or not
 
SOLVED! :D

Big Thanks to ZogG and Doc_Scrutinizer

Vromoth 2012-07-04 21:21

Re: [SCRIPT HELP] Process is running or not
 
Edit the title name to "[SOLVED][SCRIPT HELP] Process is running or not" or whatever. :)

godofwar424 2012-07-04 22:38

Re: [SCRIPT] Process is running or not
 
End result script works great here are the two scripts created from this idea! :)

INSTRUCTIONS!

Connect your N9 to your computer via USB and copy the waxmppplugin.desktop and wazapp.sh file onto your Device.

Now unplug the USB and open the Terminal, and type in the following. If any commands give a permissions error, try again as root.

Code:

cp /home/user/MyDocs/wazapp.sh /home/user/
cp /home/user/MyDocs/waxmppplugin.desktop /usr/share/applications/
chmod 755 /home/user/wazapp.sh
chmod 644 /usr/share/applications/waxmppplugin.desktop

Custom Wazapp.desktop

Wazapp.sh

Original Wazapp.desktop


If script 2 is place in /home/user/ and saved as wazapp.sh then using this .desktop file to replace the default one for Wazapp, you can achieve a Wazapp that will restart itself if it errors for any reason :)

If you Quit the app yourself, it will not restart until you do it manually :)

Scipt 1 (ZogG)

Script 2 (Doc_Scrutinizer)

ZogG 2012-07-05 15:35

Re: [SCRIPT] Process is running or not
 
Quote:

Originally Posted by godofwar424 (Post 1232066)
End result script works great here are the two scripts created from this idea! :)

Scipt 1 (VogG)

Script 2 (Doc_Scrutinizer)

If script 2 is place in /home/user/ and saved as wazapp.sh then using this .desktop file to replace the default one for Wazapp, you can achieve a Wazapp that will restart itself if it errors for any reason :)

If you Quit the app yourself, it will not restart until you do it manually :)

Custom Wazapp.desktop

fix my nick name please =)

eltoffer 2012-07-05 19:03

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
ok i used only script 2 and the new desktop file but wazapp wont load, any clue?

godofwar424 2012-07-05 19:36

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by eltoffer (Post 1232539)
ok i used only script 2 and the new desktop file but wazapp wont load, any clue?

Did you put the script in /hom/user/ and name it wazapp.sh

and put the .desktop file in /usr/share/applications/

godofwar424 2012-07-05 19:37

Re: [SCRIPT] Process is running or not
 
Quote:

Originally Posted by ZogG (Post 1232461)
fix my nick name please =)

Sorry mate :p

Fixed now

eltoffer 2012-07-05 20:06

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by godofwar424 (Post 1232558)
Did you put the script in /hom/user/ and name it wazapp.sh

and put the .desktop file in /usr/share/applications/

yup yup but no load :(


All times are GMT. The time now is 15:21.

vBulletin® Version 3.8.8