Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Probleme mit Bash Script
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
huecky
n00b
n00b


Joined: 15 Jan 2004
Posts: 21

PostPosted: Sat Sep 11, 2004 8:33 am    Post subject: Probleme mit Bash Script Reply with quote

guten morgen,

Kann jemand von euch einem Newbie mal unter die Arme greifen?

ich habe bei mir auf dem Gentoo Server einen Java chat am laufen.
Nun ist das Problem , das der mal so alle zwei drei tage abschmiert.

Um den start ein wenig zu vereinfachen, wollte ich ein script schreiben,
welches das automatisiert, also dne kill und und den startprozess.
durchgeführt wird das nicht als root sondern als normal user....
die durchzuführenden Behle gehen als user von der shell auch als einzelbefehle, aber als script nicht
ich bekomme folgende Fehlermeldung:

1]+ Done(143) nohup java -server Main_Serv (wd: ~/chat)
(wd now: ~)

Wenn ich die Fehlermeldung richtig deute, hat er probleme mit irgendeiner Pfadangabe, oder?

Ich finde aber diesen Fehler einfach nicht, da ich ja absolute Pfade angegeben habe.

Ich füge hier mal das ganze Script mit an.
wäre klasse wenn jemand mir helfen könnte

danke huecky

Code:
#! /bin/bash

echo "=========================================="
echo "=              Chatreboot                ="
echo "=========================================="
echo " "
echo "Wollen Sie wirklich den Chat neustarten? "
read A
    if [ $A = J -o $A = j ]
   then
       clear
       echo ""
       echo "=========================================="   
       echo "Chat wird beeendet - Please wait 3 seconds"
# Festlegung von den Variablen
   VAR=$(ps ax | grep java | grep -v "ps ax")
   IFS=" "
   set $VAR
       echo "die zubeendene PID ist: " $1
kill $1
       echo " "
       echo "========================================="
       sleep 3
    cd /var/www/localhost/chat && nohup /opt/blackdown-jdk-1.4.1/bin/java -server Main_Server &
       echo "=       Chat wurde neu gestartet        ="
       echo "========================================="
       exit
else
    clear
    exit
    fi
# EOF
Back to top
View user's profile Send private message
Earthwings
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 7753
Location: Germany

PostPosted: Sat Sep 11, 2004 9:06 am    Post subject: Reply with quote

Das ist zwar nicht das schönste Skript... aber ne Fehlermeldung ist die Ausgabe nicht - sagt lediglich, das der alte mit nohup gestartete Prozess nach dem kill beendet ist und wie sich das aktuelle Verzeichnis geändert hat.
Back to top
View user's profile Send private message
huecky
n00b
n00b


Joined: 15 Jan 2004
Posts: 21

PostPosted: Sat Sep 11, 2004 9:11 am    Post subject: Reply with quote

kann sein das es nicht das es nicht das schönste script ist....
ist mein erstes... naja bin für verbesserungen dankbar, wennn du mir welche geben könntest...

zum problem, ok wenn es nur das verzeichniss gewechselt hat, gib mir doc hmal bitte nen tip, warum der chat dann nicht gestartet wird, was er ja eigentlich sollte durch die nohup anweisung?
Back to top
View user's profile Send private message
huecky
n00b
n00b


Joined: 15 Jan 2004
Posts: 21

PostPosted: Sat Sep 11, 2004 4:42 pm    Post subject: Reply with quote

weiss niemand rat?
Back to top
View user's profile Send private message
Earthwings
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 7753
Location: Germany

PostPosted: Sat Sep 11, 2004 4:50 pm    Post subject: Reply with quote

Ich würde es etwa so machen:
Code:

#!/sbin/runscript

depend() {
        after apache apache2
}

start() {
        ebegin "Starting chat"
        start-stop-daemon --background --make-pidfile --pidfile /var/run/chat --start --quiet --exec <executable>
        eend $?
}

stop() {
        ebegin "Stopping chat"
        start-stop-daemon --stop --quiet --pidfile /var/run/chat
        eend $?
}


Das ganze als /etc/init.d/chat speichern. Jetzt kannst Du ganz normal mit /etc/init.d/chat start den Chat starten, mit ... stop beenden oder ... restart neustarten. Falls er mal abgestürzt ist (dann wird restart nicht klappen), kannst Du mit ... zap und danch ... start neustarten. Außerdem erhältst Du mit "rc-update add chat default" einen automatischen Start nach dem Booten.
<executable> musst Du natürlich sinnvoll ersetzen.
Back to top
View user's profile Send private message
Minox
Apprentice
Apprentice


Joined: 12 Apr 2004
Posts: 188
Location: Germany / Munich

PostPosted: Sat Sep 11, 2004 5:52 pm    Post subject: Reply with quote

Und im zweifelsfall könntest du ganz am anfang des Scripts
Code:
set -x

einfügen. Damit siehst du deutlich was passiert. Vielleicht siehst du ja dann auch den Fehler.
MfG
_________________
:!: proud to be 100% M$ free :!:
Back to top
View user's profile Send private message
huecky
n00b
n00b


Joined: 15 Jan 2004
Posts: 21

PostPosted: Sun Sep 12, 2004 5:46 pm    Post subject: Reply with quote

Earthwings wrote:

<executable> musst Du natürlich sinnvoll ersetzen.


hmmm ohje ich seh schon so ein noob wie ich bin wird das nix....

was meinst du mit sinnvoll ersetzen? Pfadangabe zum chat , zum java oder was?

mit dem set-x werde ich mal checken...

danke euch beiden, hoffe das sich das noch löst das prob
Back to top
View user's profile Send private message
Earthwings
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 7753
Location: Germany

PostPosted: Sun Sep 12, 2004 6:14 pm    Post subject: Reply with quote

Probier mal
Code:
java -server /var/www/localhost/chat/Main_Server
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum