Сценарий оболочки для запуска mysql сервера, не уже работая

Что-либо странное в журналах Windows Приложения и Системы?

Действительно ли это - ASP или веб-сайт ASP.NET (или даже что-либо еще)?

Что происходит, если Вы спрашиваете статическую страницу HTML или изображение?

1
задан 5 January 2012 в 17:15
3 ответа

Скрипт run-one - ваш друг:

sudo run-one /opt/local/share/mysql5/mysql/mysql.server start

Подробнее о run-one скрипте:
http: // blog. dustinkirkland.com/2011/02/introduction-run-one-and-run-this-one.html

Если вы не можете установить run-one по какой-либо причине,
затем скопируйте следующий код в новый файл с именем run-one :

#!/bin/sh -e
#
#    run-one - run just one instance at a time of some command and
#              unique set of arguments (useful for cronjobs, eg)
#
#    run-this-one - kill any identical command/args processes
#                   before running this one
#
#    Copyright (C) 2010 Dustin Kirkland <kirkland@ubuntu.com>
#
#    Authors:
#        Dustin Kirkland <kirkland@ubuntu.com>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

PROG="run-one"

# Cache hashes here, to keep one user from DoS'ing another
DIR="$HOME/.cache/$PROG"
mkdir -p "$DIR"

# Calculate the hash of the command and arguments
CMDHASH=$(echo "$@" | md5sum | awk '{print $1}')
FLAG="$DIR/$CMDHASH"

# Handle run-this-one invocation, by killing matching process first
case "$(basename $0)" in
        run-this-one)
                ps="$@"
                # Loop through matching pids
                for p in $(pgrep -u "$USER" -f "^$ps$" || true); do
                        # Try to kill pid
                        kill $p
                        # And then block until killed
                        while ps $p >/dev/null 2>&1; do
                                kill $p
                                sleep 1
                        done
                done
                # NOTE: Would love to use lsof, but it seems that flock()'s
                # are not persistent enough, sometimes; use pgrep/pkill now.
                # pid=$(lsof "$FLAG" | grep "^flock" | awk '{print $2}') || true
                # [ -z "$pid" ] || kill $pid

        ;;
esac

# Run the specified commands, assuming we can flock this command string's hash
flock -xn "$FLAG" "$@"

Чтобы дать разрешение на выполнение:

chmod +x run-one

Наконец, используйте ./ run-one или правильно установите Переменная среды PATH , чтобы использовать ее без указания каталога.

2
ответ дан 4 December 2019 в 01:16

Вы также можете изучить программу под названием «monit». Синтаксис и использование довольно распространены и просты.

1
ответ дан 4 December 2019 в 01:16

Не рекомендуется останавливать процесс mysqld, поскольку это может привести к потере данных или повреждению баз данных. Изящный способ - использовать mysqladmin shutdown.

-2
ответ дан 4 December 2019 в 01:16

Теги

Похожие вопросы