Hallo kann ich einen Prozess immer wieder mit einer bestimmten PID starten um es später mit einem Script zu beenden ?
Prozess mit PID bestimmter starten
Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen
-
-
-
stimmt aber wie leuft das z.b. bei einem Gameserver Interface wo man den Server starten und beenden kann ?
-
-
Bei Netzwerkserver sehe ich kein Problem - die werden doch sowieso meist nur über ihre Ports angesprochen.
Ansonsten braucht man die PIDs auch nicht zwischenspeichern. Man kann sie einfach mit folgendem Befehl auslesen
Ansonsten schau dir irgendwelche init Scripts an
PIDs mal am Beispiel von Apache:
Quellcode
- #!/bin/bash -e
- APACHE2CTL="$ENV /usr/sbin/apache2ctl"
- apache_stop() {
- PID=""
- PIDFILE=""
- AP_CONF=/etc/apache2/apache2.conf
- # apache2 allows more than PidFile entry in the config but only the
- # last found in the config is used; we attempt to follow includes
- # here, but only first-level includes are supported, not nested ones
- for i in $AP_CONF `awk '$1 ~ /^\s*[Ii]nclude$/ && $2 ~ /^\// {print $2}' $AP_CONF`; do
- PIDFILE=`grep -i ^PidFile $i | tail -n 1 | awk '{print $2}'`
- if [ -e "$PIDFILE" ]; then
- PID=`cat $PIDFILE`
- fi
- done
- if [ $? = 0 ]; then
- # if the config is ok than we just stop normaly
- if [ -n "$PID" ]
- then
- $APACHE2CTL stop
- CNT=0
- while [ 1 ]
- do
- CNT=$(expr $CNT + 1)
- [ ! -d /proc/$PID ] && break
- if [ $CNT -gt 60 ]
- then
- if [ "$VERBOSE" != "no" ]; then
- echo " ... failed!"
- echo "Apache2 failed to honor the stop command, please investigate the situation by hand."
- fi
- return 1
- fi
- sleep 1
- done
- else
- if [ "$VERBOSE" != "no" ]; then
- echo -n " ... no pidfile found! not running?"
- fi
- fi
- else
- [ "$VERBOSE" != "no" ] && echo "$errors"
- # if we are here something is broken and we need to try
- # to exit as nice and clean as possible
- # if pidof is null for some reasons the script exits automagically
- # classified as good/unknown feature
- PIDS=`pidof apache2` || true
- REALPID=0
- # if there is a pid we need to verify that belongs to apache2
- # for real
- for i in $PIDS; do
- if [ "$i" = "$PID" ]; then
- # in this case the pid stored in the
- # pidfile matches one of the pidof apache
- # so a simple kill will make it
- REALPID=1
- fi
- done
- if [ $REALPID = 1 ]; then
- # in this case everything is nice and dandy
- # and we kill apache2
- kill $PID
- else
- # this is the worst situation... just kill all of them
- #for i in $PIDS; do
- # kill $i
- #done
- # Except, we can't do that, because it's very, very bad
- if [ "$PIDS" ] && [ "$VERBOSE" != "no" ]; then
- echo " ... failed!"
- echo "You may still have some apache2 processes running. There are"
- echo "processes named 'apache2' which do not match your pid file,"
- echo "and in the name of safety, we've left them alone. Please review"
- echo "the situation by hand."
- fi
- return 1
- fi
- fi
- }
- # Stupid hack to keep lintian happy. (Warrk! Stupidhack!).
- case $1 in
- start)
- log_begin_msg "Starting apache 2.0 web server..."
- $APACHE2CTL startssl
- ;;
- stop)
- log_begin_msg "Stopping apache 2.0 web server..."
- apache_stop
- ;;
- esac
(reduziert - original unter /etc/init.d/apache2) -
Danke damit geht es
-
Wenn man schon den Namen des Przesses kennt , dann einfach mit pkill abschießen.Debian Lenny * Kernel 2.6.32 * KDE 3.5.9/10
Athlon Dual Core Processor 4850e * MSI K9N2 Diamond * 8192 MB DDR2 800
1x 1500 GB S-ATA
-
Teilen
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0
-
Tags
- PHP
- Script
- benutzer
- aktuell
- Wie
- Delphi
- Windows
- server
- starten
- VB
- Java
- is
- user
- where
- Basic
- Programm
- Python
- Visual
- befehl
- perl
- Linux
- debian
- ruby
- id
- shell
- start
- Web
- net
- auslesen
- Excel
- per
- d
- bestimmten
- if
- 7
- [
- Apache
- Hack
- #
- bash
- no
- name
- apache2
- anwendung
- vb6
- ];
- all
- prozess
- CSharp
- exe
- shellscript
- beenden
- prgramm
- failed
- init
- tomcat
- ==
- Unbekannte
- externes
- Applikation
- found
- prozesse
- process
- starting
- then
- wow
- bestimmter
- keep
- Welcher
- pid
- but
- happy
- fester
- pids
- situation
- prozessid
- kill
- server:
- apache2apache2:
- bad
- failed!
- Prozess-ID:
- 5656
- make-Skript
- task
- debain
- prozess id\
- apache2ctl
- PID-File
- according
- process!
- Proc::PID::File
- pidof
- przess
- $pid
- Stupid
- lintian
- Work!
- Hack!
- killa
- prozesses
- verbose
- bestimmer
- prozess mit pid
- puschpool
- proesse
- procvess
- if there is a pid we need to v
- prodump